Hi @Sarath ,
Please refer to:
declare @Table1 table(ID int,Code int)
insert into @Table1
values(101,998877),(102,887766),(103,776655),(104,665544),(105,554433),(106,332211)
declare @Table2 table(Code int)
insert into @Table2 values(998877),(887766),(776655),(1000),(2000),(3000)
declare @Table3 table(ID int,Flag int)
insert into @Table3 values(101,null),(102,null),(103,null),(104,null),(105,null),(106,null)
select * from @Table1
select * from @Table2
select * from @Table3
update @Table3
set Flag=case when ID in(select ID
from @Table1
where Code
in(select Code from @Table2)) then 1 else 0 end
from @Table3
select * from @Table3
If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table