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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Parsing query params from a url string using sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-26 : 10:11:46
Jason Dowdell writes "Hi Gurus,

I am trying to dig down into the details of exactly which keywords are driving traffic to my site from each search engine. I store all of those reffering urls in a column along with other information about each page request a user makes to my blog marketingshift.com. But I'm clueless when it comes to writing a sql statement that will take the referring url string and break it out into the key parts so I can then loop over them and store all of those results in a new table.

For now I'm only concerned with pulling out the actual query term which is indicated with the variable "q" in all major search engines. Here's an example of a url to parse.

http://www.google.com/search?q=marketing+blog&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

note the "q=marketing+blog"
so the keyword here would be: marketing blog

Of course it would be ideal if I could actually store values exactly like the user types them, so in this case...
http://www.google.com/search?q=%22marketing+blog%22&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

the "q=%22marketing+blog%22"

but the value the user typed originally was: "marketing blog"

I'd appreciate any help or suggestions you might have on this tricky little sql issue.

Thanks in advance!
~jason dowdell"

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-26 : 10:22:26
%22 is equal to "

Use CHARINDEX function!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -