Efficient SQL UPDATE command for many rows

后端 未结 2 679
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 10:35

My problem is not one of \"Able to\", but \"able to quickly\"

I have a table with a static number of rows for which multiple items per row need to be updated frequen

2条回答
  •  借酒劲吻你
    2020-12-22 10:45

    Have your code call the System.Data.SqlClient.SqlBulkCopy API to Bulk Insert your change data into a staging table, then use an UPDATE command to read the staging data and update your target table with it.

    The reason for this approach is that all of the methods above suffer from the same basic performance bottleneck: getting the data into SQL Server in the first place. Once it's in there, there are many ways to turn that static data into an UPDATE, all with very good performance.

提交回复
热议问题