SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Comparing Contents of 2 tables in T-SQL

By iecdba,

How can you compare two tables -- say, table A and table B  and determine if their content is the same? Assuming that A and B have same structure, here's how:
First, from set theory, recall that:
If ((|A| = |B|) && |A U B| = |A|)) ====>>>  A = B

|A| = NUMBER of rows in A
|B| = NUMBER of rows in B

Total article views: 1428 | Views in the last 30 days: 1
sqlinsider scripts