I have 4 databases with similar schema's, and I'm trying to create a query to return just the table, column pairs that exist ONLY in database 1 and do not exist in database 2, 3, or 4.
Currently I can return the symmetric difference between database 1 and 2 via the following query...
select table_name, column_name from (
select table_name, column_name from [Database1].information_schema.columns
union all
select table_name, column_name from [Database2].information_schema.columns) as tmp
group by table_name, column_name having count(*) = 1
However, in trying to isolate just those columns in database 1, and doing the same across all 4 databases, things are getting complicated. What is the cleanest solution for this query?