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)
 parameter to where clause

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2011-11-17 : 21:33:46
Hi All,

For a stored procedure we have a parameter which we will pass,when there value to parameter we don't have issue to it.

But if the parameter is null we should eliminate the where clause.

Ex:

parameter: @PI_ID

select tab from <tabname> where @pi_id=''

in this case i need to eliminate the where clause itself how do we do this,

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-11-17 : 22:39:55
WHERE SomeColumn = @Param OR @Param IS NULL
Go to Top of Page
   

- Advertisement -