Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find out changed data

Status
Not open for further replies.

Luzbel

IS-IT--Management
Apr 20, 2007
45
PR
I have Table A and Table B which are similar. Table A is the main table and makes a copy to Table B. Some records in Table A are either added or deleted. Table B is later refreshed with the records in Table A to match it. How can I pragmatically know which were the records that were deleted and added off of table A before refreshing Table B.
 
You can use the Find Unmatched wizard to build two queries, one to find deletions, and one to find additions. The sql will look something like this:

Additions:

Code:
SELECT A.ID
FROM A LEFT JOIN B 
ON A.ID = B.ID
WHERE B.ID Is Null

Records exist in table A, but not in table B.

Deletions:

Code:
SELECT B.ID
FROM B LEFT JOIN A 
ON B.ID = A.ID
WHERE A.ID Is Null

Records exist in table B, but not in table A.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top