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 part of string

Author  Topic 

sachingovekar
Posting Yak Master

101 Posts

Posted - 2010-02-25 : 03:37:22
Hi,

I want to extract a part of a string.

create table #temp1 (
string nvarchar(100))

insert into #temp1 ('DGHTYUIW_3425_987601')
insert into #temp1 ('DGHT_3412325_9876232201')
insert into #temp1 ('SSSSDGHT_3425666666_98897601')

MY OUTPUT SHOULD BE:

3425_987601
3412325_9876232201
3425666666_98897601

all characters after first "_"

Regards,
Sachin

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-02-25 : 03:52:36
[code]
select case when charindex('_', string) <> 0
then right(string, len(string) - charindex('_', string))
end
from #temp1
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sachingovekar
Posting Yak Master

101 Posts

Posted - 2010-02-25 : 04:16:22
Thanks
Go to Top of Page
   

- Advertisement -