SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL command to locate string by token
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

stevenandler
Starting Member

USA
42 Posts

Posted - 12/20/2013 :  13:02:28  Show Profile  Reply with Quote
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

USA
36953 Posts

Posted - 12/20/2013 :  13:07:34  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 12/20/2013 :  13:10:32  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 12/21/2013 :  01:06:51  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000