Prabhakaran
Prabhakaran

Reputation: 92

which method is best for Bulk Insert?

i have to insert more than 200k records in sqlserver DB.

My idea is to add the data into DATA TABLE then doing Bulk Insert, but my TL said: "insert the data into CSV file format and do the bulk insert".

Which approach is faster?

Upvotes: 1

Views: 1357

Answers (2)

pingoo
pingoo

Reputation: 2064

If the CSV file has already been created SQL Bulk Insert is by far the fastest in both performance and development time.

If your creating the data in your application you'll most likely find BulkCopy to be the easiest/fastest solution.

Either way 200k records is not a huge amount of data and should be fairly fast.

Upvotes: 3

Kilren
Kilren

Reputation: 415

Usually bulk inserting csv file is high performance insertion

BULK
INSERT Table
FROM ‘$path\$file.csv’
WITH
(
    FIELDTERMINATOR = ‘;’, 
    ROWTERMINATOR = ‘\n’,
    KEEPIDENTITY,
    TABLOCK
)

I agree with Tim Schmelter the answer may vary depending of your data source.

Upvotes: 2

Related Questions