How to compare data between two table in different databases using Sql Server 2008?

前端 未结 9 2251
一生所求
一生所求 2020-12-13 17:41

I have two database\'s, named DB1 and DB2 in Sql server 2008. These two database\'s have the same tables and same table data also. However, I want to check if there are an

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 18:09

    select * from DB1.dbo.Table a inner join DB2.dbo.Table b on b.PrimKey = a.PrimKey 
    where a.FirstColumn <> b.FirstColumn ...
    

    Checksum that Matt recommended is probably a better approach to compare columns rather than comparing each column

提交回复
热议问题