Lowell (12/6/2012)
if you've got the linked server up and running, that's 99% of it;the rest is just syntax.
something like this is how you update from another table...and it doesn't matter if the other table is local, linked server, etc.
aliases can help a lot here as well;
--syntactically correct, updates all rows, many to same value, most likely
UPDATE dbo.tabletoupdate
SET WHAREHOUSE = MyExcel.WHAREHOUSE
FROM ExcelDataSource...sheet1$ MyExcel
WHERE dbo.tabletoupdate.ItemID = MyExcel.ItemID
--much more explicit, only change rows that are different
UPDATE MyTargetTable
SET WHAREHOUSE = MyExcel.WHAREHOUSE
FROM dbo.tabletoupdate MyTargetTable
LEFT OUTER JOIN ExcelDataSource...sheet1$ MyExcel
ON MyTargetTable.ItemID = MyExcel.ItemID
WHERE MyTargetTable.WHAREHOUSE <> MyExcel.WHAREHOUSE
Good stuff Lowell! Have you ever tried an UPDATE through OPENROWSET like this?
Just wondering, because I haven't either. I've found this kind of integration to Excel to be somewhat of a pain in the past.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St