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
) a
group by col1
select *,'In table1 only'
from @table1
except
select *,'In table1 only'
from @table2
union
select *,'In table2 only'
from @table2
except
select *,'In table2 only'
from @table1
union
select *,'In table1 only'
from @table1
except
select *,'In table1 only'
from @table2
union
select *,'In both'
from @table2
intersect
select *,'in both'
from @table1
Jim
Everyday I learn something that somebody else already knew