Можно использовать представление (которое ссылается на целевую таблицу) в операторе слияния:
create table t1
(
id int,
colA int
)
go
create table t2
(
id int,
colB int
)
go
create view dbo.testview
as
select id, colB
from t2
except
select id, colA
from t1
go
insert into t2(id, colB) values (1, 2)
go
--populate t1 with the values of t2 (that do not exist yet in t1)
merge t1 as t
using testview as s on t.colA = s.colB
when not matched by target then
insert(id, colA)
values(id, colB);
go
select *
from t2;
select *
from t1;
go
insert into t2(id, colB) values (1, 2)
merge t1 as t
using testview as s on t.colA = s.colB
when not matched by target then
insert(id, colA)
values(id, colB);
go
select *
from t2;
select *
from t1;
go
drop view testview;
drop table t1;
drop table t2;
go