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 |
svibuk
Yak Posting Veteran
62 Posts |
Posted - 2013-09-28 : 01:44:34
|
i have a SP with where condition as where id=@id and month=@month and Eid=@Eidwht i need is if @Eid=0 i need to display all the reocrdsif Eid>0 then display only that particular reocrdi tried where id=@id and month=@month and Eid=case when @Eid=0 then Eid>0 elseEid=@EidEndbut its giving me errorIncorrect syntax near '>'. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-09-28 : 03:10:30
|
[code]where (id=@id and month=@month and Eid=@Eid)OR @Eid=0[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
svibuk
Yak Posting Veteran
62 Posts |
Posted - 2013-09-28 : 03:27:12
|
quote: Originally posted by visakh16
where (id=@id and month=@month and Eid=@Eid)OR @Eid=0 i dont have any record with eid =0if eid =0 the i need to display all the records that where eid<>0 or eid>0------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-09-28 : 03:38:06
|
quote: Originally posted by svibuk
quote: Originally posted by visakh16
where (id=@id and month=@month and Eid=@Eid)OR @Eid=0 i dont have any record with eid =0if eid =0 the i need to display all the records that where eid<>0 or eid>0------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
Thats exactly what i've doneplease try it firstits @Eid = 0 ie parameter = 0 not the field value Eid------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|