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
 substring

Author  Topic 

kalyan.cse05
Yak Posting Veteran

74 Posts

Posted - 2012-07-16 : 03:37:27
I have a entry for a column as "ABC_12".But i need to extract only "ABC". How can i do that?

kalyan Ashis Dey

ebi007
Starting Member

15 Posts

Posted - 2012-07-16 : 03:46:31
SELECT substr("ABC_12",1,3)

---------------------------
there is no limits only God can stop me.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-07-16 : 04:31:30
More generic

select substring(col,1,charindex('_',col)-1) from table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kalyan.cse05
Yak Posting Veteran

74 Posts

Posted - 2012-07-16 : 05:29:34
exactly 2nd one is generic...Thanks for your help..:)

kalyan Ashis Dey
Go to Top of Page
   

- Advertisement -