July 7, 2005 at 11:34 am
Please someone rescue me. I have a string like this:
'action=acct_zip&id=1B25B81JVJT&eid=FD05063&custnbr=281050&ky=FD05063&oc=$99 Free Shipping&mwn=&zip=90650&email=lafaithhome@yahoo.com'
How can I use my select statement to split it up into 3 columns like this:
Custnbr Zip Email
281050 90650 lafaithhome@yahoo.com
My due date is today. Please urgently help!
Minh Vu
July 7, 2005 at 11:52 am
I set the string to a variable to help in the readability.
Declare @String varchar(1000)
set @String =
'action=acct_zip&id=1B25B81JVJT&eid=FD05063&custnbr=281050&ky=FD05063&oc=$99 Free Shipping&mwn=&zip=90650&email=lafaithhome@yahoo.com'
select substring(@String,(charindex('&custnbr=',@String) + 9), charindex('&', @String, (charindex('&custnbr=',@String) + 9)) - (charindex('&custnbr=',@String) + 9)) as custnbr,
substring(@String,(charindex('&zip=',@String) + 5), charindex('&', @String, (charindex('&zip=',@String) + 5)) - (charindex('&zip=',@String) + 5)) as zip
,substring(@String,(charindex('&email=',@String) + 7), 250) as Email
-- Results
custnbr,zip,Email
281050,90650,lafaithhome@yahoo.com
July 7, 2005 at 4:46 pm
Fantastic!
I really appeciate your help!
Minh Vu
July 8, 2005 at 7:17 am
there's a bit of design issue here ;
the web page that this querystring was posted to had all those values in the Request.Querystring collection in the name-value combinations you wanted, but instead of grabbing the portions of the string and saving them, the whole string was saved to your db instead; you should tweak that page to put the values into the proper columns instead of a "catch all" field that holds the whole querystring.
your page should be grabbing Request.Querystring("CustNbr"), Request.Querystring("zip") and Request.Querystring("email") and saving it to your db;
here's a really simple way to see the name/value pairs:
For Each Key in Request.QueryString
Response.Write Key & ": " & Request.QueryString(Key) & "<BR>"
Next
Lowell
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply