Run a large SQL script in MS-SQL server | Solution: Insufficient memory to continue the execution of the program
Today one of my team mates came to me with a script file of 157 mb. He said he wanted to execute it so that the DB can be filled with data and respective stored procedures.
I thought it to be a simple issue and just opened it in the SQL management studio created a db as in the SQL file and executed the file by clicking F5.
And bham….
It gave me an error of low memory :“Insufficient memory to continue the execution of the program”
I did some googling and came to know that such large scripts are recommended to be executed through command line interface.
I thought it might come of help to others like me. So i am documenting the process.
NOTE : The db I am executing this script file is on my own PC. I mean it is a local server on which i have the DB.
Step1: Open cmd as administrator.
Step 2: The following is the syntax of the command that i used:
SQLCMD -d database -i filename.sql
Execute this command with your custom parameters.
-d is followed by the database name on which you are executing the command.
-i is followed by the path of the file of the script file. For example, d:\script.sql