Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Simple update query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

5 Posts

Posted - 11/08/2013 :  04:09:15  Show Profile  Reply with Quote
Hi all,
Im very new to writing sql scripts, i wrote the following code in access sql but when i copy it into SQL express 2012 i get an error saying
"Incorrect syntex near the keyword 'LEFT'"

Any ideas.

UPDATE dbo_TblMaster LEFT JOIN Tbl_RentalData ON dbo_TblMaster.Serial_Number = Tbl_RentalData.[Asset Serial Number] SET dbo_TblMaster.Current_Status = IIf([Tbl_RentalData].[Asset Serial Number]=[dbo_TblMaster].[Serial_Number],"On Circuit","Off Circuit"), dbo_TblMaster.Supplier_MPID = [Tbl_RentalData].[CustomerReference], dbo_TblMaster.Supplier_Group = [Tbl_RentalData].[Group_Supplier], dbo_TblMaster.Meter_Install_Date = [Tbl_RentalData].[Original Installation Date];

Thank you

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 11/08/2013 :  04:36:31  Show Profile  Reply with Quote

 SET m.Current_Status = IIf(rd.[Asset Serial Number]=m.[Serial_Number],"On Circuit","Off Circuit"), 
 m.Supplier_MPID = COALESCE(rd.[CustomerReference],m.Supplier_MPID)
 m.Supplier_Group = COALESCE(rd.[Group_Supplier], m.Supplier_Group)
 m.Meter_Install_Date = COALESCE(rd.[Original Installation Date],m.Meter_Install_Date)
 FROM dbo_TblMaster m
 LEFT JOIN Tbl_RentalData rd
 ON m.Serial_Number = rd.[Asset Serial Number] 

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000