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)
 Conditional where clause

Author  Topic 

ultraman
Starting Member

18 Posts

Posted - 2004-11-01 : 14:11:12
Hi !

I want to create a SP that receives 8 parameters. Those parameters can be empty (0 or '' value) and are to be used in the WHERE clause. My question is : how can I customize the WHERE clause according to the parameters that actually have a value other than 0 or '' ?

Example :
SELECT * FROM TABLE WHERE 
if(@Param1 > 0)
FIELD1 = @Param1


--------------
Ultraman

X002548
Not Just a Number

15586 Posts

Posted - 2004-11-01 : 14:54:39


Have a look

http://weblogs.sqlteam.com/brettk/archive/2004/05/05/1312.aspx



Brett

8-)
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-11-01 : 15:51:00
Another useful link:

http://weblogs.sqlteam.com/jeffs/archive/2003/11/14/513.aspx
Go to Top of Page

ultraman
Starting Member

18 Posts

Posted - 2004-11-02 : 11:15:55
Thanks a lot guys, your infos were very helpful, especially yours ehorn, since it was a case closer to mine.

--------------
Ultraman
Go to Top of Page
   

- Advertisement -