1
我想利用合并语法,但它不工作合并语法错误
请帮我这个
create table tgt(id int,name varchar(10),age int)
insert into tgt values(1,'x',21),(2,'y',22),(3,'z',23)
create table src(id int,name varchar(10),age int)
insert into src values(1,'x1',24),(2,'x2',27),(4,'y1',27),(5,'z1',29),(3,'z',23)
merge tgt t using src s
on t.id=s.id
when matched then update src s
set s.id=t.id,
s.name=t.name,
s.age=t.age
when not matched then
insert(id,name,age) values(s.id,s.name,s.age);
错误消息
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near 'src'.
难道我的答案回答你的问题?如果是,请考虑接受它。 – zhongxiao37 2014-09-09 07:29:31