This code seems legit to me, i cannot figure out why it wont run!
please help :)
create table #test
(
col1 varchar(6) not null,
col2 numeric(5,2) not null,
col3 varchar(5) not null,
col4 numeric(4,0) not null
)
MERGE into table1 a
using #test b on a.col1 = b.col1
when matched then
update
set
col4 = -1
when not matched then
insert
col1,
col2,
col3,
col4
values
b.col1,
b.col2,
b.col3,
b.col4
The error is:
Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'into'.
thanks in advance!