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 2008 Forums
 Transact-SQL (2008)
 SQL Query Help

Author  Topic 

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-10-31 : 01:01:06
Please guide me this T-SQL is right to you? This is part of bigg S.P
* I am sorry i couldn't put all detail/logic of the store procedure here*


****************************************

CASE WHEN (SELECT CID From Claim
Where CID in (select CID From Transaction T)
THEN 'YES' ELSE 'NO' END Result

*******************************************

I am getting error..

Please let me know where i am wrong. Thank You in advance...

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-10-31 : 01:31:59
This needs to be in a select statement - not sure what you are trying to do but it should probably be a join
maybe

select C.CID, CASE WHEN T.CID is null then 'NO' else 'YES' end
from Claim C
left join (select distinct CID from transaction) T
on C.CID = T.CID

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -