Spot the incorrect syntax please..!

  • With the below code, I keep on getting the following error:

    Server: Msg 170, Level 15, State 1, Line 1

    Line 1: Incorrect syntax near '('.

    Can anyone spot the problem please..?! Thanks!

    UPDATE ((APTLive.dbo.Person INNER JOIN APTLive.dbo.Employee

    ON APTLive.dbo.Person.PersonUID = APTLive.dbo.Employee.PersonUID)

    INNER JOIN APTLive.dbo.Employer ON APTLive.dbo.Employee.EmployerUID = APTLive.dbo.Employer.EmployerUID)

    INNER JOIN APTLocal.dbo.[User] ON APTLive.dbo.Person.PersonUID = APTLocal.dbo.[User].PersonUID

    SET APTLocal.dbo.[User].PersonUID = "999999"

    WHERE APTLive.dbo.Employer.EmployerUID= '1252191';

  • Your syntax is completely incorrect.

    Update TargetTable

    SET TargetColumn = SourceColumn

    FROM TargetTable INNER JOIN ....

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Well not really, it would almost be correct in Access which is probably where that all started.

    The deletes and updates (especially in joins) are quite differente betwen Access and SQL Server.

  • Yep, it came from Access! THanks a million, I'm in a mad rush..

    This worked perfect:

    UPDATE APTLocal.dbo.[User]SET PersonUID = '999999'

    FROM ((APTLive.dbo.Person INNER JOIN APTLive.dbo.Employee

    ON APTLive.dbo.Person.PersonUID = APTLive.dbo.Employee.PersonUID)

    INNER JOIN APTLive.dbo.Employer ON APTLive.dbo.Employee.EmployerUID = APTLive.dbo.Employer.EmployerUID)

    INNER JOIN APTLocal.dbo.[User] ON APTLive.dbo.Person.PersonUID = APTLocal.dbo.[User].PersonUID

    WHERE APTLive.dbo.Employer.EmployerUID= '1252191';

  • Ninja's_RGR'us (12/18/2008)


    Well not really, it would almost be correct in Access which is probably where that all started.

    I haven't worked in Access for so long I can't remember anything about it's syntax.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • And there I was thnking you knew everything about everything ;). Now that dream is gone for me.

  • Ninja's_RGR'us (12/18/2008)


    And there I was thnking you knew everything about everything ;). Now that dream is gone for me.

    There I was thinking you dreamed about SQL Server, and all the time you were dreaming about Gail:D

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • I think I can safely assume that I have no possible good answer to that post so I'll just shut up :w00t::hehe:.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply