English 中文(简体)
将 4 500 000 记录插入带有 c# 的 sql 服务器数据库
原标题:how to fast Insert 4,500,000 record into sql server database with c#

I have a program in c# that Insert 4,500,000 record into sql using ExecuteNoneQuery and take too long to insert I need a fast way to insert that take maximum about 10 minutes however when I insert 4,500,000 record from another table to my table via management studio it take 3 minutes

最佳回答
问题回答

正如 Oded 已声明的那样, 此选项的起点是 SqlBulkCopy 。 但是, 如果您对数据库有控制权, 您也应该检查数据库中的恢复模型设置为简单或“ 布尔克登入 ” 。 否则您将受到 SQL 服务器创建日记条目的重击 。 您也需要确保设置 TableLock 的 SqlBulkCoption 。

这两个是直向前方的。 也可以与 SqlBulCupy BatchSize 设置和交易模式( 参见 United InternalTransAction) 一起玩, 但是这些设置比较难提供建议, 因为对于不同的假想方案, 最佳设置可能非常不同 。 如果使用 TableLock 和检查 Rescovery 模型, 并不很理解您想要的速度, 那么您就可以开始使用批次大小, 但是它是一个灰色区域 。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签