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
 General SQL Server Forums
 New to SQL Server Programming
 SQL SERVER T-SQL - MERGE

Author  Topic 

teaton
Starting Member

1 Post

Posted - 2011-08-05 : 07:47:25
Hi,

The code below does not work. There are no actual errors shown on the code itself but when I try to execute teh ALTER store procedure I get the following error message
:
Msg 10739, Level 15, State 1, Procedure up_AmendInstanceImport_rs, Line 44
The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.

I understand I am not using the Target table but does anyone know if this can be done?


MERGE dbo.tblInstances AS TARGET
USING dbo.tblInstanceImport AS Source
ON (Target.InstanceName = Source.InstanceName)
WHEN MATCHED THEN
UPDATE
SET Target.[Home] = Source.[Home]
,Target.[Version] = Source.[Version]
,Target.[DateCollected] = GetDate()
WHEN NOT MATCHED BY TARGET THEN
INSERT (tblNewInstance.[Name]
,tblNewInstance.[InstanceName]
,tblNewInstance.[DateCollected]
)
VALUES (Source.Name
,Source.Instance
,GETDATE()
);

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-08-05 : 12:06:00
Remove the "tblNewInstance." from the WHEN NOT MATCHED insert column list.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -