dolly_do
dolly_do

Reputation: 127

Insert multiple records using insert statement in SQL Server database in an efficient way

I have to insert about million records into database using insert statement. The records I have them stored as .sql files, then I split them into several files and start execute them via SQL Server Management Studio.

It takes many hours to do so and I searched on line to find a better way to do, but I can't find one. I use SQL Server 2014 Developer edition.

Any advice?

Upvotes: 0

Views: 83

Answers (2)

Black.Jack
Black.Jack

Reputation: 1957

You should definetely try:

Bulk Insert

Probably you'll need to prepare comma separeted file, like csv. Otherwise you'll need an OOP approach.

Upvotes: 1

user8513344
user8513344

Reputation:

So basically the [.sql File] has a bunch of insert statements written and you are execution one by one?

The only way I could think of is open that file only copying the insert Value into a .csv file, ofcourse make a proper.csv file with all the columns and comma separating ...., and then in SQL use -> Task ->Import Data and load it into a table,

Or open the file in xml and replace all the techical words/characters like 'Insert, values, () ..' with blank spaces and then convert the file to .csv

Again assuming its all for the same table,

Upvotes: 0

Related Questions