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 2008 Forums
 Transact-SQL (2008)
 search query?

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2012-06-14 : 16:16:05
Hi friends,

I want to handle a seacrh operation where the parameters are sent from the front ends.
In my scenario say there are two parameters, I want to get write a query where in it satisfies the following

1) parameter1 and parameter 2 both are null values
2)parameter1 and parameter 2 both have some values
3)parameter1 has value but param2 is null
4)parameter1 is null but param2 has value...

How can i achieve this

Thank You

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-06-14 : 16:25:48
That is called a Catch-all query. Perhaps, this blog will help:
http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/
Go to Top of Page

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2012-06-14 : 18:21:45
Thanks Lamprey..It worked fine..But i have got another problem..How to check for empty strings...Should i check them in thef ront end or in the backend query..Please suggest..Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-14 : 22:42:42
quote:
Originally posted by akpaga

Thanks Lamprey..It worked fine..But i have got another problem..How to check for empty strings...Should i check them in thef ront end or in the backend query..Please suggest..Thanks



instead of checking @param is null
just like nullif(@param,'') is null

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -