Comparing large tables using checksum

  • I have two large tables, in terms of number of records as well as number of columns. Recordcount is equal.

    I need to find differences in record values accross all columns. Tried to use checksum(*), but the syntax did not work, also tried to use it as computed column, and tried HashBytes as well.

    Does somebody has an example ? If that's impossible, what would be a better method ?

    Thanks

  • Have you considered using the MERGE statement? Greatly modified to NOT change anything simple to find those rows.

    MERGE dbo.Departments AS d

    USING dbo.Departments_delta AS dd

    ON (d.DeptID = dd.DeptID)

    WHEN NOT MATCHED THEN -- modify to insert records into a temp table

    INSERT (DeptID, DeptName, Manager)

    VALUES (dd.DeptID, dd.DeptName, dd.Manager)

    WHEN NOT MATCHED BY SOURCE THEN

    DELETE -- modify to insert records into a temp table

    OUTPUT $action,

    inserted.DeptID AS SourceDeptID, inserted.DeptName AS SourceDeptName,

    inserted.Manager AS SourceManager,

    deleted.DeptID AS TargetDeptID, deleted.DeptName AS TargetDeptName,

    deleted.Manager AS TargetManager;

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply