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
 conditional where statement

Author  Topic 

jeh3404
Starting Member

1 Post

Posted - 2010-07-16 : 10:35:53
I am having trouble trying to figure out how do do a conditional where statement. Can anyone help me with how to accomplish the following?

WHERE field1='value1' and
field2=@parameter1
if @parameter2 <> NULL then
and field3=@parameter2

Is this possible?

Thanks for any help that can be provided.

Jim

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-16 : 10:39:33
where field1 = 'value1'
and field2 = @parameter1
and (@parameter2 is null or field3 = @parameter2)


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

- Advertisement -