Bulk Insert Sql Server millions of record

后端 未结 3 1060
长情又很酷
长情又很酷 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.

提交回复
热议问题