declare @a table (ID int, Val char(1));
declare @b table (ID int, Val char(1));
insert into @a values (1, 'a'), (2, 'b');
insert into @b values (1, 'a'), (2, 'b');
-- nothing is returned, data is identical
select * from @a except select * from @b;
-- ID Val
-- ----------- ----
-- update one row in b
update @b set Val = 'd' where ID = 1;
-- insert one row in a
insert into @a values (4, 'f')
-- The rows from a with ID in (1, 4) are returned: ID = 1 has been
-- modified in b, and ID = 4 is a new row in a.
-- There is no way to know why exactly the rows appear in the results
select * from @a except select * from @b;
-- ID Val
-- ----------- ----
-- 1 a
-- 4 f
-- Insert one row in b to see that even though the row has been inserted in b
-- it is not included in the results
insert into @b values (5, 'g')
select * from @a except select * from @b;
-- ID Val
-- ----------- ----
-- 1 a
-- 4 f
17 People are following this question.