here's a few waysDECLARE @Table1 Table ( col1 CHAR(1))DECLARE @Table2 Table ( col1 CHAR(1)) INSERT INTO @Table1 values ('a'),('b'),('C')INSERT INTO @Table2 values ('e'),('f'),('C') SELECT col1,sum(distinct tbl) FROM ( select *,1 as Tbl from @table1 union all select *,2 from @table2) agroup by col1select *,'In table1 only'from @table1exceptselect *,'In table1 only'from @table2unionselect *,'In table2 only'from @table2exceptselect *,'In table2 only'from @table1unionselect *,'In table1 only'from @table1exceptselect *,'In table1 only'from @table2unionselect *,'In both'from @table2intersectselect *,'in both'from @table1
JimEveryday I learn something that somebody else already knew