Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

can any body tell me how can I compare two rows of two differnt tables(same columns), I want to get the chages between them


Thanks
Posted

1 solution

If you are using SQL 2005+ then use the following which will give you all the rows which are different:

SQL
SELECT * FROM (SELECT * FROM table1
               EXCEPT
               SELECT * FROM table2) a
UNION ALL
SELECT * FROM (SELECT * FROM table2
               EXCEPT
               SELECT * FROM table1) b
 
Share this answer
 
Comments
Code_seeker_ 4-Nov-11 2:57am    
tx its effective but
Can I get only the column in which we have change ?
Mehdi Gholam 4-Nov-11 3:08am    
You can specify a column and check that by replacing the * with a column name.

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