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
 using case with JOIN

Author  Topic 

svibuk
Yak Posting Veteran

62 Posts

Posted - 2013-10-11 : 03:13:11

IN SP i have the
AND EI.IID =TL.IID AND EI.GID=TL.GID

and TL.QID=EI.ID WHERE EI.TYPE='P'

but i need and TL.QID=EI.ID only when
@QID>0
if not > 0 the i dont need to add and TL.QID=EI.ID
i tried below

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-11 : 03:15:45
use boolean logic to bypass


...
AND EI.IID =TL.IID AND EI.GID=TL.GID

and (TL.QID=EI.ID OR @QID<=0 )
WHERE EI.TYPE='P'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

svibuk
Yak Posting Veteran

62 Posts

Posted - 2013-10-11 : 07:42:45
Thanks

solved the issue
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-11 : 08:15:13
cheers

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -