Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Update multiple rows on one column with excel file

Author  Topic 

drtduarte
Starting Member

12 Posts

Posted - 2009-10-26 : 11:00:39
Dear Friends,

I need to update all rows from column vendor from an sql database, I have the updated data on excel file, here you have the example:

Excel Data:

ID Vendor
1 20
2 14
3 10
4 21


SQL Data:
ID Vendor
1 2
2 10
3 45
4 60

Can this be done with an sql statment?

Regards,
David

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-26 : 12:10:38
I'd import the excel sheet into SQL 1st, then update table.


UPDATE t
SET Vendor = xl.vendor
FROM yourTable t
JOIN importedExcelTable xl
On xl.id = t.id
Go to Top of Page

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-10-26 : 23:02:30
Hi,
You can import the data to SQL by using a wizard to a temp table from there u can use the update statement to update all the records by using the join.
Go to Top of Page
   

- Advertisement -