SQLTeam.com | Weblogs | Forums

How to get exact changes on compare


#1

Hello,
The keyword "EXCEPT" will get me the rows for differences in tables while comparing. I am looking for only the exact data that changed instead of whole row.
For example: I have a row of columns: A, B, C
With EXCEPT, I get the whole row that changed
The only value that changed at this point is in column B
So all I want is column B, instead of whole row.
How do I accomplish this?

Thank you.


#2

One can possibly write a query to parse out that information, but I suspect that is not going to be as simple as using the EXCEPT keyword. Usually what I do is to use EXCEPT both ways and then copy the results to an Excel sheet to do the comparison.

SELECT * FROM A EXCEPT SELECT * FROM B ORDER BY Something
SELECT * FROM B EXCEPT SELECT * FROM A ORDER BY Something

That would work well if you only have changed rows. If you have new rows inserted or rows deleted from either table, would make an excel comparison harder.


#3

EXCEPT will only give me the whole rows. So this is not a solution. But I have now figured out. Thanks.


#4

I would love to know the solution, can you please share?