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 2005 Forums
 Transact-SQL (2005)
 whats wrong in query

Author  Topic 

ajmaly
Starting Member

11 Posts

Posted - 2010-08-01 : 12:49:21
TableA

UID Name
1 A

2 B

3 D


TableB

UID Name
1 A

2 C



Above is the 2 table..and I wrote below SQL Query to compare between two..but what wrong in below query (not working)...

;with cte as (select
sum(case when exists (select 1 from TableA where TableA.UID = TableB.UID
and
TableA.name <> TableB.name) then 1 else 0 end as [CountBad]
from TableB)
select case when CountBad > 0 then 'NO' else 'YES' end from cte


ajmal

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-08-01 : 13:39:05
There is a closing parentheses missing.


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

- Advertisement -