简体   繁体   中英

Update data with elements from excel using stored procedure in SQL Server

I have a table in my database having the following attributes:

  • registration number
  • name
  • totalGift

I receive an excel file from the financial department having registration number and totalGift at end of each month.

For each row of the excel file, I have to update the row having the registration number and set the totalGift value in database.

Can someone help me achieve this?

Is there any way to achieve this with a stored procedure and OpenRowset?

I would add a column to the spreadsheet with this (or a similar formula):

="INSERT INTO [TABLENAME] (monthName, [registration number], totGift) values ('20220131','" & [Enter Cell Value of RegistrationID] & "'," & [Enter Cell Value of total gift] & ")"

Copy and paste that down the sheet and that will give you all the insert statements to run in SSMS.

There are items in that statement that need to be replaced.

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