简体   繁体   English

使用c#winforms将大量数据从文本文件导入到sql

[英]Importing huge data from text file to sql using c# winforms

I am wanting to add the ability to import massive CSV files into a table in the database. 我想添加将大量CSV文件导入数据库中的表的功能。 I've built an SSIS package that does this, but I just wanted to make sure that this was the correct way of doing it. 我已经构建了一个SSIS包,但我只是想确保这是正确的方法。

The text files are millions of rows with 50 columns. 文本文件是数百万行,包含50列。 They don't open in notepad or notepad++ a lot of times. 它们很多时候都没有在记事本或记事本++中打开。 The SSIS package handles them with no problem and gets everything imported. SSIS包处理它们没有问题,并导入所有内容。 Is SSIS the right way to deal with this? SSIS是解决这个问题的正确方法吗? I just need to pass the file location parameter to the job and execute it right? 我只需要将文件位置参数传递给作业并执行它吗? Is there an easier way that I am overlooking? 有一种我更容易忽视的方式吗?

The text files are millions of rows with 50 columns 文本文件是数百万行,包含50列

Small. 小。 Why an SSIS package? 为什么选择SSIS包?

They don't open in notepad or notepad++ 它们不能在记事本或记事本++中打开

because both OPEN them - there is no need to open them and load them all into memory, a proper application can read them line by line. 因为它们都打开它们 - 没有必要打开它们并将它们全部加载到内存中,正确的应用程序可以逐行读取它们。

Is SSIS the right way to deal with this? SSIS是解决这个问题的正确方法吗?

No. SImply because the title is: Importing huge data from text file to sql using c# winforms 不。仅仅因为标题是:使用c#winforms将大量数据从文本文件导入到sql

As Winforms can do that effectively - I am inserting around 100.000 rows into a database - in C# with quit eeasy coding (except some pages and a day to get sqlbulkcopy to work properly) and you say nothing about any transformations, SSIS just is another not needed technology AND makes things complicated (as in: more to install, or hav a packag on the server but then find a location for the file that the server can reach etc. 正如Winforms可以有效地做到这一点 - 我将大约100.000行插入到数据库中 - 在C#中使用quit eeasy编码(除了一些页面和一天让sqlbulkcopy正常工作)并且你没有说任何转换,SSIS只是另一个没有所需技术并使事情变得复杂(例如:更多要安装,或者在服务器上有一个包装,但随后找到服务器可以到达的文件的位置等。

I am all for SSIS and if you have a larger SSIS infrastructure or do a lot of processing etc. and it makes architectural sense in a larger context - yes. 我是SSIS的全部,如果你有一个更大的SSIS基础设施或做大量的处理等,它在更大的背景下具有建筑意义 - 是的。 But as the question stands, without additional reasons - absolutely not. 但问题是,没有其他原因 - 绝对不是。

Heck, there is a good chance you can load the whole thing in one command into SQL server as SQL Server has some CSV processing capabilities: 哎呀,由于SQL Server具有一些CSV处理功能,因此很有可能可以将一个命令中的所有内容加载到SQL服务器中:

http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/ http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-服务器/

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

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