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.
Author |
Topic |
urzsuresh
Starting Member
30 Posts |
Posted - 2011-01-20 : 04:07:12
|
Hi, Below one is my sample table.Create Table t ( Id int, [Status] varchar(50), StDate datetime,)Insert into tSelect 1,'Active',GETDATE()+5 Union Select 2,'In-Active',GETDATE()+10 Union Select 3,'Active',GETDATE()+14 Union Select 4,'Active',GETDATE()+45--ProcedureCreate Procedure test (@id int,@status varchar(50),@stdt datetime,@eddt datetime)AsBegin Select * from t Where (@id=0 or Id=@id) and (@status='ALL' or [Status]=@status) and (StDate between @stdt and @eddt or 1=1)EndWhen i execute the below one exec test 1,'All',null,nullhere am getting one rows. its correct.test 0,'All','2011-01-25 14:11:40.293','2011-02-03 14:11:40.293'need to get Three rowsMy requirement, If pass date value am getting wrong result.How can i change the above procedureSuri |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-01-20 : 04:15:34
|
or 1=1 is always true No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|