I have a problem similar to this StackOverflow question, except that I need to exclude certain fields from the comparison but still include it in the result set.
I'm penning the problem as locally symmetric difference.
For example Table A and B have columns X,Y,Z and I want to compare only Y,Z for differences but I still want the result set to include X.
Old style SQL for a full join - A concatenated with B, excluding rows in B also in A (the middle):
ANSI Style:
The coalesce's are there for safety; I've never actually had cause to write a full outer join in the real world.
If what you really want to find out if two table are identical, here's how:
If that returns a non-zero result, then there is a difference. It doesn't tell you which table it's in, but it's a start.