Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse dynamic string

Status
Not open for further replies.

redtoad

Programmer
Jan 28, 2002
51
US
I would like to pull some data out of field that contains URL's. For instance my the URL may be I need to pull out the name of the group, which is between group=(name)&function.

I have tried using charindex and substring functions, but always seem to get more of the URL returned than needed.

Any insight would be helpful. Thanks.
 
Hi,

This looks more like an ASP question, y dont u use Request.QueryString("Group") to get the values, then all the hassles of string manipulation is eliminated.

Sunil
 
assuming the field name of the url is url the following will work

select left(substring(url,charindex('group=',url)+6),len(url)),charindex('&',substring(url,charindex('group=',url)+6,len(url)))-1) from mytable

 
How about this function. Not pretty but functional.

Select name=left(right(col_name,len(col_name)-charindex('group=',col_name)-5),charindex('&function',right(col_name,len(col_name)-charindex('group=',col_name)-5))-1)

If you are using SQL 2000, I recommend writing a User-Defined Function to parse the string. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Thanks for all the responses. I was able to follow tlbroadbent's suggestion to get the result I was looking for. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top