Reputation: 415
I have a Table and I need to update a single column with a new set of quantities, which I have from an Excel Spreadsheet. I already have the Rows I require, but cannot figure out how to update multiple rows at once.
I have tried going to Edit Top 200 Rows and modified the SQL there to select the rows I require, but unfortunately you cannot paste down a column.
Any Ideas?
Upvotes: 2
Views: 7529
Reputation: 489
I always add columns to write an update or insert text between data columns like dat:
Then I copy this data to sql managment studio and replace tab ' ' to empty char '' and run queries.
If the data doesn't match to my table straight from excel i create #TMP table and fill data to it and then operate to data in tmp table in sql.
Upvotes: 3
Reputation: 4645
If you want to update it without wrinting every single update-statement, you'll need a column in your excel that you can uniquely match to a column in the sql table.
I had to do this too a few days ago and I imported the excel sheet into a temporary table (rightclick on Database -> Tasks -> Import Data..) and wrote an update query with a join:
UPDATE t
SET t.columnToUpdate = temp.newValue
FROM TableToUpdate AS t
INNER JOIN temporaryTable AS temp
ON t.Id = temp.Id
Upvotes: 0