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
 General SQL Server Forums
 New to SQL Server Programming
 If URL parameter exists change sql query

Author  Topic 

vogabonz
Starting Member

1 Post

Posted - 2011-07-12 : 07:31:11
Is it possible to change a query based on the existence of a URL variable. I would like to have something like the following

SELECT *
FROM someTable
WHERE someColumn = (if some URL passed variable exists match to it)
otherwise just select all


Vogabonz

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-07-12 : 07:40:15
select * from Table where (Column = @URL or @URL is NULL)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -