Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server - Running large script files

I have a database table on a development server that is now fully populated after I set it running with an import routine for a CSV file containing 1.4 million rows.

I ran the Database Publishing Wizard on the table, and now I have a 286MB SQL script on my local machine. The problem is, I can't figure out how to run it. If I load it into SQL Server Management Studio Express I get an alert window that says "The operation could not be completed".

Any ideas on how I can get this SQL script to run?

like image 954
tags2k Avatar asked Oct 21 '08 16:10

tags2k


2 Answers

use the sqlcmd tool to execute the file..

sqlcmd -S myServer\instanceName -i C:\myScript.sql 

In case your have an unexplained "script error" for large sql files (> 100MB) which includes several INSERT, just replace "INSERT INTO" by "GO INSERT INTO" in your file, which will reduce size of transaction.

like image 187
Gulzar Nazim Avatar answered Oct 12 '22 08:10

Gulzar Nazim


This tool (Big SQL Script File Runner) on CodePlex will run any size script file with log and GUI.

like image 29
Alobidat Avatar answered Oct 12 '22 08:10

Alobidat