-2

How to find if one table is replica of other table in SQL

Deolas
  • 312
  • 3
  • 10

2 Answers2

1

In SQL Server, you can compare the results of:

SELECT checksum_agg(checksum(*))
FROM Table1;

SELECT checksum_agg(checksum(*))
FROM Table2;

You could create a join with these as sub-queries if you want, too.

You may wish to use binary_checksum() instead of checksum(). The doc says that checksum() will treat strings that are equal as equal according to the collation (i.e., 'hello' and 'HELLO' if the collation is case-insensitive), while binary_checksum() compares the raw binary values of characters.

Bacon Bits
  • 30,782
  • 5
  • 59
  • 66
0

This works for MySQL:

CHECKSUM TABLE table_1, table_2;
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252