Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help with merge statement

Author  Topic 

kralco626
Starting Member

1 Post

Posted - 2009-07-31 : 10:32:37
I am trying to exicute this query in sql server management studio. I don't understand why i am getting an error.

Thanks for any 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!

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-31 : 13:33:06
Did you mean to post this is the SQL2008 forum?
quote:
Originally posted by kralco626

I am trying to exicute this query in sql server management studio. I don't understand why i am getting an error.

Thanks for any 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!

Go to Top of Page
   

- Advertisement -