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
 Getting differences from a table

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2011-07-14 : 09:04:47
I have two tables Test019 and T16019

How do I get the records that are not in table Test019

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-14 : 09:11:33
if you are on SQL 2005 or higher you can use except keyword.
select * from T16019 except select * from Test019 
For that to work, the two table structures have to be the same. Same columns, same ordinal positions etc. If not, you can explicitly list the columns:

select col1,col2,col3 from T16019
except
select col1,col2,col3 from Test019
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2011-07-14 : 09:20:16
Perfect...thanks!
Go to Top of Page
   

- Advertisement -