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
 SQL command to locate string by token

Author  Topic 

stevenandler
Starting Member

42 Posts

Posted - 2013-12-20 : 13:02:28
I am using SQL 2005 and I'm trying to find a T-SQL command that will allow me to retrieve a sub string based on the token. For instance, if I had a string like this:

abc^defgh^ij^klmnop^qrs

Let assume the token is the ^ and I want to get the string at the third token klmnop.

is there a simple one line command that I can use to retrieve this data?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-12-20 : 13:07:34
You can use the PARSENAME function if your data has up to four parts.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-12-20 : 13:10:32
Maybe you could make use a split/parse function:
http://www.sqlservercentral.com/articles/T-SQL/62867/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-21 : 01:06:51
quote:
Originally posted by stevenandler

I am using SQL 2005 and I'm trying to find a T-SQL command that will allow me to retrieve a sub string based on the token. For instance, if I had a string like this:

abc^defgh^ij^klmnop^qrs

Let assume the token is the ^ and I want to get the string at the third token klmnop.

is there a simple one line command that I can use to retrieve this data?





see

http://visakhm.blogspot.in/2013/05/get-nth-positioned-string-from.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -