Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Stripping fields to contain last 6 digits

Author  Topic 

jjz
Starting Member

31 Posts

Posted - 2009-03-17 : 08:24:34
Hi all

please assist.

I am trying to strip an alpha numeric field in SQL Server 2005. The disired output is the last 6 digits of this field.

e.g. AU3071801890
desired output: 801890

How do I go about doing that?

Please also note that I cannot do this one by one as I need to do this on a couple of records. I have already imported this file.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-17 : 08:26:17
If you are sure that last 6 fields will be numeric , you can simply use...

select right(column_name,6) from yourtable
Go to Top of Page

jjz
Starting Member

31 Posts

Posted - 2009-03-17 : 08:35:17
thanx a mil, it worked perfectly for the numeric fields like you said, however I have alpha numeric as well
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-17 : 08:36:42
can you post the exact case and output just to be sure ?
Go to Top of Page

jjz
Starting Member

31 Posts

Posted - 2009-03-17 : 09:37:43
here is what i am trying to do.

22795B0IKQ88
desired output: 0IKQ88

THX


Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-17 : 09:47:23
ok. Then the same thing should work.

select right(column_name,6) from yourtable
Go to Top of Page

jjz
Starting Member

31 Posts

Posted - 2009-03-17 : 10:15:12
you've been a great help. thank you
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-17 : 10:32:48
np
Go to Top of Page
   

- Advertisement -