create table #t1 ( col1 int, col2 int, col3 int )create table #t2 ( col1 int, col2 int, col3 int )insert into #t1 select 1,1,1 insert into #t1 select 2,2,2 insert into #t1 select 3,3,3insert into #t2 select 1,1,1 insert into #t2 select 2,2,2 insert into #t2 select 4,4,4select * from #t1 select * from #t2delete t from #t1 t where not exists(select null from #t2 where t.col1= col1 and t.col2=col2)
(
col1 int,
col2 int,
col3 int
)create table #t2
(
col1 int,
col2 int,
col3 int
)insert into #t1 select 1,1,1
insert into #t1 select 2,2,2
insert into #t1 select 3,3,3insert into #t2 select 1,1,1
insert into #t2 select 2,2,2
insert into #t2 select 4,4,4select * from #t1
select * from #t2delete t
from #t1 t
where not exists(select null from #t2 where t.col1= col1 and t.col2=col2)
----------- ----------- -----------
1 1 1
2 2 2(2 row(s) affected)