Thursday, 2 June 2011

SQL: Checksum

Compare 2 tables for duplicates.

There are 3 types of checksum:
  1. checksum: Is not case sensitive.
  2. binary_checksum: Is case sensitive.
  3. checksum_agg: Aggregates the results to check table as a whole.
example:

SELECT *

FROM [Person].[Contact] a

inner join [Person].[Contact] b

on a.ContactID = b.ContactID

WHERE BINARY_CHECKSUM(a.[NameStyle],a.[Title],a.[FirstName]) = BINARY_CHECKSUM(b.[NameStyle],b.[Title],b.[FirstName])

No comments:

Post a Comment