批量插入3M记录到SQLExpress
当尝试将 3M 记录从 CSV 文件批量插入到 SQLExpress 数据库时,该过程抛出超时异常,该异常设置为 30 秒。我尝试将连接超时设置为 1800,但该过程再次引发了相同的异常。
有谁知道抛出异常是由于记录太多还是超时设置不正确?
下面是连接字符串、查询语句和文件中的行,
connectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=simulatorDB.mdf;Integrated Security=True;Connect Timeout=1800;User Instance=True"
query = "BULK INSERT real_data FROM '" + path + "' WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')"
AFAB19476C2CEEEE101FFA45FD207BA8B6185B29,539EE0643AFC3A3BE3D20DC6BE7D5376DC536D34,9800,58,29,24,34,2
如果有人建议修复所描述的问题,我将非常感激。
谢谢你!
While trying to bulk insert 3M records from CSV file to SQLExpress database the procedure throw the timeout exception which was set to 30s. I tried to set the Connect Timeout to 1800 but again the procedure threw the same exception.
Does anyone know whether the exception is thrown due to too many records or the timeout was not set correctly?
Below is the connection string, query statement and row from file
connectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=simulatorDB.mdf;Integrated Security=True;Connect Timeout=1800;User Instance=True"
query = "BULK INSERT real_data FROM '" + path + "' WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')"
AFAB19476C2CEEEE101FFA45FD207BA8B6185B29,539EE0643AFC3A3BE3D20DC6BE7D5376DC536D34,9800,58,29,24,34,2
I would be very thankful if anyone suggested a fix for the described issue.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是您需要设置的连接超时 - 您需要增加的是 命令超时。
至于导入 3M 记录需要多长时间,这完全取决于您要导入的表 - 即,它是新表还是已经存在一些数据/索引的现有表,该表是否正在被其他进程积极使用。
It's not the connection timeout you need to set - what you need to increase is the Command Timeout.
As for how long importing 3M records will take, it depends exactly on the table you are importing into - i.e. if it's a new table or existing table with some data/indexes already on, whether the table is actively being used by other processes.