having trouble with joins

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anthony97
    New Member
    • Aug 2009
    • 24

    having trouble with joins

    I can't get this code to run on SQL server without the following error

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

    UPDATE [tblAcsChargeAmt s]
    JOIN [T Accessorials_Es timated]
    ON [tblAcsChargeAmt s].[Shipment Id] = [T Accessorials_Es timated].[Shipment Id]
    AND [tblAcsChargeAmt s].[Load Id] = [T Accessorials_Es timated].[Load Id]
    AND [tblAcsChargeAmt s].[Acs Code] = [T Accessorials_Es timated].[Acs Code])
    SET [tblAcsChargeAmt s].[Est AP Amt] = [T Accessorials_Es timated].[AP Est Acs Amt],
    [tblAcsChargeAmt s].[Est AR Amt] = [T Accessorials_Es timated].[AR Est Acs Amt]
    WHERE [tblAcsChargeAmt s].[Est AP Amt] = 0
    OR [tblAcsChargeAmt s].[Est AR Amt] = 0;
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Here is the example from SQL servers help documentation

    [code=sql]
    UPDATE titleauthor
    SET title_id = titles.title_id
    FROM titles INNER JOIN titleauthor
    ON titles.title_id = titleauthor.tit le_id
    INNER JOIN authors
    ON titleauthor.au_ id = authors.au_id
    WHERE titles.title = 'Net Etiquette'
    AND au_lname = 'Locksley'
    [/code]


    you need to model your update query like that.

    Just a hint....

    There is a lot of help available in MSSQL's help (with examples) that answers questions like this. You access that help from "query analyser"....no t from "Enterprise manager".
    PS Im talking from the perspective of MSSQL Server 2000 here. It's probably different in later versions

    Comment

    Working...