What's the fastest way to bulk insert a lot of data in SQL Server (C# client)

前端 未结 8 1214
予麋鹿
予麋鹿 2020-11-28 22:39

I am hitting some performance bottlenecks with my C# client inserting bulk data into a SQL Server 2005 database and I\'m looking for ways in which to speed up the process.

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 23:20

    Here's how you can disable/enable indexes in SQL Server:

    --Disable Index ALTER INDEX [IX_Users_UserID] SalesDB.Users DISABLE
    GO
    --Enable Index ALTER INDEX [IX_Users_UserID] SalesDB.Users REBUILD

    Here are some resources to help you find a solution:

    Some bulk loading speed comparisons

    Use SqlBulkCopy to Quickly Load Data from your Client to SQL Server

    Optimizing Bulk Copy Performance

    Definitely look into NOCHECK and TABLOCK options:

    Table Hints (Transact-SQL)

    INSERT (Transact-SQL)

提交回复
热议问题