Issue: "Insufficient memory to continue the execution of the program (mscorlib) in Microsoft SQL Server Management Studio when executing a large SQL script.
Running the scripts using Microsoft SQL Server Management Studio (SSMS) will not work. Try running the erring SQL script from command prompt as it is much lighter.
How to run SQL scripts from command prompt?
- Open Command Prompt on your computer
- Type the following command (without quotes, < and > symbols):
sqlcmd -S <servername\instance" -e -d <database name> -i <SQL file path>
If SQL Server instance is not set, omit the instance name. The command will now look like:
sqlcmd -S <servername" -e -d <database name> -i <SQL file path>
sqlcmd -S computer401 -e -d schooldb -i D:\SQL Scripts\create_procedures.sqlThe SQL script which failed to execute in Microsoft SQL Server Management Studio (SSMS) should now run.
How to find the SQL server instance name in Microsoft SQL Server Management Studio ?
- Open Microsoft SQL Server Management Studio (SSMS) and login
- Right-click on the server (root of the tree on the left sidebar)
- Click on properties
- In the "Server Properties" windows, click on "View Connection Properties"
- In the "Connection Properties" window, under "Product", check "Instance Name" property.