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
 SQL Server Development (2000)
 small SP syntax problem

Author  Topic 

jparker
Posting Yak Master

118 Posts

Posted - 2005-01-12 : 07:58:26
If one of my variables is equally to 0 I don't want to include one line in my sql statement.

Do I have to have two versions of the whole select statement within my stored procedure of can I put a condition statement (an IF) round that one particular line?

Could you please advise with an example please

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-01-12 : 08:17:34
no you cannot but around a portion of a query. You could if it was dynamic SQL, but thats probably not your solution here.


Try using code that would negate the condition if the variable equals 0

i.e.

Where ...
and (Age = @myVar or @myVar = 0)

Corey
Go to Top of Page
   

- Advertisement -