March 13, 2020 at 7:07 pm
You've been around long enough to know that you should provide sample data and expected results.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 13, 2020 at 9:24 pm
Here's a guess at what you want:
(
SELECT 'Table1' TableName,ID,Col1,Col2,Col3,Col4
FROM Table1 t1
WHERE EXISTS(SELECT * FROM Table2 t2 WHERE t2.ID = t1.ID)
EXCEPT
SELECT 'Table1' TableName,ID,Col1,Col2,Col3,Col4
FROM Table2
)
UNION ALL
(
SELECT 'Table2' TableName,ID,Col1,Col2,Col3,Col4
FROM Table2 t2
WHERE EXISTS(SELECT * FROM Table1 t1 WHERE t1.ID = t2.ID)
EXCEPT
SELECT 'Table2' TableName,ID,Col1,Col2,Col3,Col4
FROM Table1
)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply