Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:01:49+00:00 2026-05-26T23:01:49+00:00

I am executing the following merge statement in SQL Server 2008: MERGE PopulationData AS

  • 0

I am executing the following merge statement in SQL Server 2008:

MERGE 
PopulationData AS a
USING ImagesData AS b
ON a.ID = b.ID
WHEN MATCHED THEN
UPDATE SET a.SURNAME = 'joe123'
WHEN NOT MATCHED THEN INSERT(a.ID,a.SURNAME)
VALUES (12454,'joe123');

I have the following error:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'AS'.

Can anyone tell me where the syntax error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:01:50+00:00Added an answer on May 26, 2026 at 11:01 pm

    Parsing your query in SQL Management Studio gives me the following error:

    Msg 10739, Level 15, State 1, Line 7 The insert column list used in
    the MERGE statement cannot contain multi-part identifiers. Use single
    part identifiers instead.

    I then remove the identifiers…

    MERGE 
    PopulationData AS a
    USING ImagesData AS b
    ON a.ID = b.ID
    WHEN MATCHED THEN
    UPDATE SET a.SURNAME = 'joe123'
    WHEN NOT MATCHED THEN INSERT(ID,SURNAME)
    VALUES (12454,'joe123');
    

    …and the query parses successfully. Therefore, the syntax error is almost certainly not coming from your MERGE statement. Are you really executing only the statement you posted, or is it part of a larger script or procedure? And if you double-click the error message, it should highlight the line where the syntax error is (at least with SQL 2008).

    Update: I noticed that you have tagged the question for SQL 2005 and 2008, but MERGE is only supported in SQL 2008. Parsing the query under SQL 2005 gives the syntax error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am successfully executing the following query in SQL Server 2008 built into VS2008:
I'm executing the following statement: UPDATE TOP(1) dbo.userAccountInfo SET Flags = Flags | @AddValue
When executing the following (complete) SQL query on Microsoft SQL Server 2000: SELECT B.ARTIFACTTNS,
I'm using following update or insert Oracle statement at the moment: BEGIN UPDATE DSMS
On executing the following code using 'Macro Definitions Set 1', I encounter the error
Executing the following SQL: drop function f go in MS Sql Server Management Studio
How would I go about executing the following Hibernate query using the criteria API.
I m executing following: db2 -tvsf ./sql/update_product.sql I have used eclipse for editing update_product.sql
I have the following PL/SQL being sent to a remote oracle 11gr2 server via
I am executing the following statement: ;WITH cte AS ( SELECT 1 as rn,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.