declare @tbl1 as table(id int, dt varchar(10)); insert in...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @tbl1 as table(id int, dt varchar(10));
insert into @tbl1
select 1, '2023-01-11' union all
select 2, '2022-01-12' union all
select 3, '2022-01-13';

declare @tbl2 as table(id int, dt varchar(10));
insert into @tbl2
select 1, '2023-12-11' union all
select 2, '2022-01-12' union all
select 3, '2022-12-13';

select t2.* from @tbl2 as t2
join @tbl1 as t1 
on t1.id = t2.id
where t1.dt <> t2.dt;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results