简体   繁体   中英

Import data from Excel to SQL Server by id

I would be grateful if you can tell me how import data from Excel into a specific column based specific id - my amount of data is huge.

Table in Excel:

id description
1 description for id 1
2 description for id 2
3 description for id 3
4 description for id 4

My table in SQL Server

id name description
1 one null
2 two null
3 three null
4 four null

I want a query something like this:

if (id in excel == id in SQL Server)
    SQL.description = excel.description 

In my view, At first you can import all row from excel file into a table -eg excelTable-and finally update mainTable from join table with new table.

1)In SSMS right on your database/Tasks/Import Data 2)Select from excel file 3)update main table update mainTable set mainTable.description = excelTable.description from maintable inner join execlTable on mainTable.id = execlTable.id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM