Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,How can I compare 2 tables in the same database and retreive data from one of the tabels that does do exist in the other.Thank you simon
sodeep
Master Smack Fu Yak Hacker
7174 Posts
Posted - 2008-12-03 : 12:39:30
select * from table 1exceptselect * from table 2
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-12-03 : 13:33:04
Also another method would be
select *from(select *,1 as cat from table 1union allselect *,2 from table 2)tgroup by <all fields except cat here>having sum(case when cat=2 then 1 else 0 end)=0