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.
| Author |
Topic |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2005-03-01 : 05:11:26
|
| I have 2 tables in 2 different databases that should have the same records (minus the identity)How can I compare the 2 tables (in 2 different db's ) to only see records that are not in both?Is there any easy query to do this? |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2005-03-01 : 09:38:36
|
| select * from db1.dbo.table1 ainner join db2.dbo.table2 bon a.datacol1 = b.datacol1and a.datacol2 = b.datacol2and a.datacol3 = b.datacol3....and a.datacoln = b.datacolnwhere a.datacol1 is nullunionselect * from db2.dbo.table2 ainner join db1.dbo.table1 bon a.datacol1 = b.datacol1and a.datacol2 = b.datacol2and a.datacol3 = b.datacol3....and a.datacoln = b.datacolnwhere a.datacol1 is nullor look to use Red-Gate.COM (Data Compare) technology for a more professional/repeating version. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|