We have some queries that work sorta like this, which might be what you need:UPDATE DSET Column1 = S.Column1, Column2 = S.Column2, ...FROM DestinationDatabase.dbo.MyTable AS D JOIN SourceDatabase.dbo.MyTable AS S ON S.MyPKColumn = D.MyPKColumnWHERE (S.Column1 <> D.Column1 OR (S.Column1 IS NULL AND D.Column1 IS NOT NULL) OR (S.Column1 IS NOT NULL AND D.Column1 IS NULL) ) AND (S.Column2 <> D.Column2 OR (S.Column2 IS NULL AND D.Column2 IS NOT NULL) OR (S.Column2 IS NOT NULL AND D.Column2 IS NULL) ) ...INSERT INTO DestinationDatabase.dbo.MyTable( Column1, Column2, ...)SELECT S.Column1, S.Column2, ...FROM SourceDatabase.dbo.MyTable AS SWHERE NOT EXISTS ( SELECT * FROM DestinationDatabase.dbo.MyTable AS D WHERE D.MyPKColumn = S.MyPKColumn )
Couple of caveats:The "<>" test won't work for TEXT columns (we compare DATA_LENGTH() and CONVERT(varchar(8000), S.MyTextColumn) <> CONVERT(varchar(8000), D.MyTextColumn) to text-compare the first 8,000 characters only (and then only if the DATA_LENGTH() is the same)Also, if you want to compare case SENSITIVE (and assuming your database is case INsensitive), then you need to use a Binary Collate in the comparison of any char/varchar/text columnsKristen