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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Extract a substring from a string

Author  Topic 

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2007-10-23 : 09:05:30
Hi All,

I need to extract some part of the column value from a table.

For example:
The values in the columnA are like
IS01\costsk
IS01\palletp
IS01\garbc

I need to get the substring
costsk
palletp
garbc

Can anyone tell me how to fetch only that part from the string?

Thanks,
-P


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-23 : 09:06:40
Try

Select substring(col,charindex('\',col)+1,len(col)) from table

Madhivanan

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

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2007-10-23 : 09:42:45
Thanks Madhivanan
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-23 : 09:47:32
Did you mean "everything after the '\', wherever it appears" then?

Or "everything from 6th character onwards"?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-23 : 09:48:44
quote:
Originally posted by Kristen

Did you mean "everything after the '\', wherever it appears" then?

Or "everything from 6th character onwards"?

Kristen


I think it is case 1

Madhivanan

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

Kristen
Test

22859 Posts

Posted - 2007-10-23 : 09:50:55
I think you are right. But the spec. was a little "loose"
Go to Top of Page
   

- Advertisement -