现有表leiweitest1(CS1字段为主键),leiweitest2(无主键).
leiweitest1(源表)的数据为:
leiweitest2(目标表)的数据为:
我的merge语句:
merge into leiweitest1 a
using (select b.cs1, b.cs2 from leiweitest2 b) b
on (a.cs1 = b.cs1 AND B.CS2 <> 'XX')
when matched then
update set a.cs2 = b.cs2
when not matched then
insert (a.cs1, a.cs2) values (b.cs1, b.cs2);
运行该语句报错:违反唯一约束条件。
请问这是为什么呢? 我on条件不能过滤掉源表的一些数据吗?求大神解答。