Your best bet is to use SSIS to import the spreadsheet into a work table (not a temp table!) and execute the update join from there as an "Execute SQL Task". Maybe something like this:
update a
set a.newproductcode = b.newproductcode
from dbo.product a
inner join dbo.wkProduct b
on a.ProductCode = b.ProductCode
Granted, it's not super efficient if it's a one-time update. But if it is to be periodic, you can schedule the thing as long as your spreadsheet format doesn't change.
It sounds like that's pretty much what you're already doing though. If you do wind up scheduling it, just be sure to truncate your work table at the start of the Control Flow!
BitBlt
Practically a Posting Shark
894 posts since Feb 2011
Reputation Points: 482
Solved Threads: 148
Skill Endorsements: 14
If it's Excel and it's a one time thing - or even if it's re-occuring rarely - then I'd concatenate the values into SQL statements in Excel and copy paste them in SQL. It can either be the update statement itself or it can be an insert statement for your temp/working table.
You should end up with a formula in Excel like this ="update product set newproductcode = '" & A2 & "' where productcode = '" & B2 & "'". Fill it down to all your rows and copy/paste it to SQL. it's faster than all the alternatives.
adam_k
Veteran Poster
1,057 posts since Jun 2011
Reputation Points: 274
Solved Threads: 205
Skill Endorsements: 11