Bulk Insert Sql Server millions of record

后端 未结 3 1058
长情又很酷
长情又很酷 2020-12-03 08:13

I have a Windows Service application that receives a stream of data with the following format

IDX|20120512|075659|00000002|3|AALI                 |Astra Agro         


        
相关标签:
3条回答
  • 2020-12-03 09:03

    First, download free LumenWorks.Framework.IO.Csv library.

    Second, use the code like this

    StreamReader sr = new TextReader(yourStream);
    var sbc = new SqlBulkCopy(connectionString);
    sbc.WriteToServer(new LumenWorks.Framework.IO.Csv.CsvReader(sr));
    

    Yeah, it is really that easy.

    0 讨论(0)
  • 2020-12-03 09:06

    If you are writing this in C# you might want to look at the SqlBulkCopy class.

    Lets you efficiently bulk load a SQL Server table with data from another source.

    0 讨论(0)
  • 2020-12-03 09:20

    You can use SSIS "Sql Server Integration Service" for converting data from source data flow to destination data flow. The source can be a text file and destination can be a SQL Server table. Your conversion executes in bulk insert mode.

    0 讨论(0)
提交回复
热议问题