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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a Querystring using TSQL.

Status
Not open for further replies.

Jesus4u

Programmer
Feb 15, 2001
110
0
0
US
I need each param parsed out of this string. I am having trouble parsing if the vars vary in length.

Data: ec=TTT&oc=CRM&tot=501&UID=88997

Code:
(SELECT
ID, IP, TID, TheUserDetails.UserID as UserID, 
--Parsing
Querystring,
SUBSTRING(Querystring, CHARINDEX('ec=',Querystring) + 3, CHARINDEX('&', Querystring) - 4) as EC,
SUBSTRING(Querystring, CHARINDEX('oc=',Querystring) + 3, CHARINDEX('&', Querystring) - 4) as OC,
SUBSTRING(Querystring, CHARINDEX('tot=',Querystring) + 4, CHARINDEX('&', Querystring) - 5) as TOT,
SUBSTRING(Querystring, CHARINDEX('uid=',Querystring) + 4, 50) as UID
FROM WebLog l LEFT JOIN
dbo.TheUserDetails ON 
l.TID = TheUserDetails.TrackID)


Exams Passed: 70-152, 70-175, 70-176, 70-100
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top