Re: Script / Function ... to find difference b/w 2 similar tables Assuming by differences you mean rows in A not in B as well as vice
versa, a good solution would be
create table t1 (a int,b int)
create table t2 (a int,b int)
insert into t1 values (1,2)
insert into t1 values(3,4)
insert into t1 values(5,6)
insert into t2 values(1,2)
insert into t2 values(3,7)
insert into t2 values(5,6)
select sum(t) ,a,b from
(select 1 as t,* from t1
union all
select 2 as t,* from t2
) as both
group by a,b
this way you see both kinds of differences as 1 or 2, and 3 means no
difference (you can add having sum(t)<3 not to see them)
hope this helps
Tzvika |