Click here to Skip to main content
15,889,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
destintion table should be updated..
Posted

1 solution

Use BINARY_CHECKSUM

Suppose you have PrimaryKey Column(or any Unique column) on two tables, let's say Id


SQL
SELECT T1.*
FROM
(
SELECT *, CAST(BINARY_CHECKSUM(*) AS BIGINT)  AS BCHECKSUM
FROM Table1
--WHERE Id IN(.,.,..) -- To be used in subsequent iteration
)AS T1
LEFT OUTER JOIN
(
SELECT Id, CAST(BINARY_CHECKSUM(*) AS BIGINT) AS BCHECKSUM
FROM Table2
--WHERE Id IN(.,.,..) -- To be used in subsequent iteration
)AS T2
ON T1.Id = T2.Id
WHERE T1.BCHECKSUM <> T2.BCHECKSUM


Now you have unmatched rows... Note down Ids for unmatched and continue with BINARY_CHECKSUM(Col1, Col2, ..., Coln) (i.e. initially we used *, now we select specific columns to narrow down unmatch to specific column's row) on the above(but it restrict to the Ids that are not matching) script and keep on removing each column in step until you see BINARY_CHECKSUM is same.
 
Share this answer
 
v2
Comments
Kuthuparakkal 14-Sep-12 0:33am    
You should know what do you want, I gave you an idea for inspiration.
dineshvishe 14-Sep-12 0:36am    
alteast i want changes rows..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900