sql Update from another table

-- Using a JOIN (faster)
Update #QuickBuyReport
Set OrderID = O.OrderID
From dbo.tbl_Order O
Inner Join #QuickBuyReport QBR On O.BasketID COLLATE DATABASE_DEFAULT = QBR.BasketID

-- Using an inner query (slower)
Update [tbl_MyTable]
Set [tbl_MyTable].Price = (
	Select [tbl_MyTable_20110104].Price
	From [tbl_MyTable_20110104]
	Where [tbl_MyTable_20110104].Code = [tbl_MyTable].Code
)
Updates a table with data from another table.

Updated: Tuesday 25th August 2015, 19:37pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.