Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I handle large SQL SERVER batch inserts?

I'm looking to execute a series of queries as part of a migration project. The scripts to be generated are produced from a tool which analyses the legacy database then produces a script to map each of the old entities to an appropriate new record. THe scripts run well for small entities but some have records in the hundreds of thousands which produce script files of around 80 MB.

What is the best way to run these scripts?

Is there some SQLCMD from the prompt which deals with larger scripts?

I could also break the scripts down into further smaller scripts but I don't want to have to execute hundreds of scripts to perform the migration.


1 Answers

If possible have the export tool modified to export a BULK INSERT compatible file.

Barring that, you can write a program that will parse the insert statements into something that BULK INSERT will accept.

like image 197
NotMe Avatar answered Dec 06 '25 13:12

NotMe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!