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
 Seperating or parsing a value

Author  Topic 

mclovin
Starting Member

15 Posts

Posted - 2011-12-21 : 08:10:01
Hello,
This is my issue I have this value you in a column "Exception Hardware Refresh,US STATUS: Missing,US STATUS: Backup" and what i need to bring back and show for that value is the words after US STATUS:. Which in the case would be Missing,Backup. Any help on how to extract those words from that value would be appreciated Thanks.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-12-21 : 08:45:19
PATINDEX and CHARINDEX will help, along with SUBSTRING.
Go to Top of Page

mclovin
Starting Member

15 Posts

Posted - 2011-12-21 : 12:46:36
Thanks RickD for the response but I have being trying different situation using those function and I’m not able to get it done.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-12-21 : 13:07:40
Something like this:
REPLACE(STUFF(yourCol,1,CHARINDEX('US STATUS:',yourCol)-1,''),'US STATUS:','')
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-21 : 13:14:00
[code]
DECLARE @strCol varchar(8000)
SET @strCol = 'Exception Hardware Refresh,US STATUS: Missing,US STATUS: Backup'
SELECT SUBSTRING(@strCol,CHARINDEX('US STATUS:',@strCol)+11,7)
[/code]


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

mclovin
Starting Member

15 Posts

Posted - 2011-12-21 : 13:15:35
Thanks guys I’m going to give them a try. really appreciate it
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-21 : 13:19:08
ooo

very nice



DECLARE @strCol varchar(8000)
SET @strCol = 'Exception Hardware Refresh,US STATUS: Missing,US STATUS: Backup'
SELECT SUBSTRING(@strCol,CHARINDEX('US STATUS:',@strCol)+11,7)
SELECT REPLACE(STUFF(@strCol,1,CHARINDEX('US STATUS:',@strCol)-1,''),'US STATUS:','')




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

mclovin
Starting Member

15 Posts

Posted - 2011-12-23 : 13:24:19
Sorry Guys for not responding quicker but the solutions that you guys give me worked I went with sunitabeck solutions Thanks guys
Go to Top of Page
   

- Advertisement -