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 2005 Forums
 Transact-SQL (2005)
 WHERE Clause Problem

Author  Topic 

thir13enth
Starting Member

3 Posts

Posted - 2011-11-27 : 03:03:30
Hello, I have a stored procedure.

Column1 is related to @param1 and @param2 which are both nullable.

When @param1 and @param2 are both null, my select statement should ONLY return those rows with Column1 value as null.

Any idea how to achieve this? BTW, dynamic T-SQL is not allowed. Thanks!

vikki.seth
Yak Posting Veteran

66 Posts

Posted - 2011-11-27 : 04:17:45
Can you post your SP here to better understand?
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-11-27 : 08:15:43
You probably need a WHERE clause in your select statement something like this:

WHERE
(@param1 IS NULL AND @param2 IS NULL AND Column1 IS NULL)
-- OR
-- OTHER CONDITIONS IN WHERE CLAUSE HERE
Go to Top of Page

thir13enth
Starting Member

3 Posts

Posted - 2011-11-27 : 12:13:23
Hello this answer is already solved using simple boolean logic like sunitabeck posted. Thanks!
Go to Top of Page
   

- Advertisement -