By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

having trouble with joins

P: 24
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 [tblAcsChargeAmts]
JOIN [T Accessorials_Estimated]
ON [tblAcsChargeAmts].[Shipment Id] = [T Accessorials_Estimated].[Shipment Id]
AND [tblAcsChargeAmts].[Load Id] = [T Accessorials_Estimated].[Load Id]
AND [tblAcsChargeAmts].[Acs Code] = [T Accessorials_Estimated].[Acs Code])
SET [tblAcsChargeAmts].[Est AP Amt] = [T Accessorials_Estimated].[AP Est Acs Amt],
[tblAcsChargeAmts].[Est AR Amt] = [T Accessorials_Estimated].[AR Est Acs Amt]
WHERE [tblAcsChargeAmts].[Est AP Amt] = 0
OR [tblAcsChargeAmts].[Est AR Amt] = 0;
Sep 24 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,134
Here is the example from SQL servers help documentation

Expand|Select|Wrap|Line Numbers
  1. UPDATE titleauthor
  2.    SET title_id = titles.title_id
  3.    FROM titles INNER JOIN titleauthor 
  4.       ON titles.title_id = titleauthor.title_id 
  5.       INNER JOIN authors
  6.       ON titleauthor.au_id = authors.au_id
  7.    WHERE titles.title = 'Net Etiquette'
  8.       AND au_lname = 'Locksley'

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"....not from "Enterprise manager".
PS Im talking from the perspective of MSSQL Server 2000 here. It's probably different in later versions
Sep 24 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.