SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

Gregorys05
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

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

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

 UPDATE m
 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
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.14 seconds. Powered By: Snitz Forums 2000