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
 Optional Parameters in SQL Server 2005

Author  Topic 

Sivangari
Starting Member

16 Posts

Posted - 2010-10-19 : 06:11:07
I have a stored procedure with many optional parameter and one of the type is bit type.I am passsing that value in select statement like this

Select * from Orders where (IsCompleteOrderFlag like coalesce(@completeStatus,IsCompleteOrderFlag))
Here @completeStatus is bit type ,but it is not fetching the correct value from the table it always return null only.

Help me to use bit in optional parameter.

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-19 : 06:35:43
do you get records when you execute :

Select * from Orders where IsCompleteOrderFlag = 0

Select * from Orders where IsCompleteOrderFlag = 1
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-10-19 : 07:18:29
Also do you have NULL values in your bit column & why are you using like clause to find value for a bit datatype?

PBUH

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-19 : 08:14:30
Select * from Orders
where @completeStatus is null or IsCompleteOrderFlag=@completeStatus



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

- Advertisement -