简体   繁体   English

将65535行插入SQL Server 2008

[英]Insert 65535 rows into SQL Server 2008

I want to insert 65545 rows from csv to SQL Server 2008 in C#.net but I need to rearrange data in my program. 我想在C#.net中将65545行从csv插入SQL Server 2008,但是我需要在程序中重新排列数据。

Which way is the best way to insert those rows into SQL Server, SQLBulkOperations, or using transaction and insert row by row, or using multi insert. 哪种方法是将这些行插入SQL Server,SQLBulkOperations或使用事务并逐行插入或使用多重插入的最佳方法。

65K rows is not that many really, but I suggest using System.Data.SqlClient.SqlBulkCopy because it's fast now, and also fast later when your requirements expand. 65K的行确实不是很多,但是我建议使用System.Data.SqlClient.SqlBulkCopy因为它现在速度很快,并且在需求扩展时也很快。 It's also handy to keep an implementation of it around - this sort of thing seems to come up fairly regularly. 保持其实现也很方便-这种事情似乎经常出现。

I have an answer to another SO question that has psuedocode describing how I used SqlBulkCopy in my last big project: 我对另一个具有psuedocode的SO问题有一个答案,该问题描述了我如何在上一个大项目中使用SqlBulkCopy:
Sql server 2008 - performance tuning features for insert large amount of data SQL Server 2008-用于插入大量数据的性能调整功能

It sounds like you want to do the same sort of thing as I, except reading the data from a CSV rather than another database file. 听起来您想要做与我相同的事情,只是从CSV而不是从另一个数据库文件读取数据。 Look into a good CSV parsing library for a performant solution to that part of the problem. 寻找一个好的CSV解析库,以寻求针对该部分问题的高效解决方案。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM