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
 Moving from JET SQL to T SQL

Author  Topic 

rob41
Yak Posting Veteran

67 Posts

Posted - 2009-08-07 : 14:10:56
I'm new to SQL server and I am trying to convert sql from access to sql server 2005. I'm attaching the code below:

UPDATE [tblShipments] LEFT JOIN [T Bill To 2] ON ([tblShipments].[Shipment Id] = [T Bill To 2].[Shipment Id]) AND ([tblShipments].[Load Id] = [T Bill To 2].[Load Id])
SET [tblShipments].[Bill To] = [T Bill To 2]![Bill To]
WHERE ((([tblShipments].[Bill To]) Is Null));

this is the error message I'm getting.

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'LEFT'.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'tblShipments'.

I have surfed the web and found how to convert IIf from access to sql server by changing it to CASE WHEN, I have not had any luck on what to do with joins.

Any help is greatly appreciated.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-08-07 : 16:36:27
Try this...

UPDATE t 
SET t.[Bill To] = t1.[Bill To]
FROM [tblShipments] t
LEFT JOIN [T Bill To 2] t1
ON t.[Shipment Id] = t1.[Shipment Id]
AND t.[Load Id] = t1.[Load Id]
WHERE t.[Bill To] IS NULL
Go to Top of Page
   

- Advertisement -