MyTechMantra.com
Connect With MyTechMantra.com

Like Us on Facebook    Follow Us on Twitter     Subscribe to our Feeds     Subscribe to NewsLetter































How to Fix Cannot execute script. Insufficient memory to continue the execution of the program (mscorlib) error in SQL Server

Read Comments   |   Related Topics: SQL Server Management Studio Tips > Next Topic: Database Backup & Restore Tips


Introduction

Database Administrators often need to get involved in code deployments wherein they release new code from one environment to another. As a best practice it is highly recommended to note down issues faced during code deployment and address them before you move with code deployment to higher environments such as Pre-Production or Production.

One of the most errors faced by DBAs during code deployment is "Cannot execute script. Insufficient memory to continue the execution of the program (mscorlib)". The reason why you receive the above error is SQL Server Management Studio is when SSMS cannot handle errors in case if the script fails because the script file is very big generally above 30 MB.

How to Fix Insufficient memory to continue the execution of the program (mscorlib) error in SQL Server

How to Fix Insufficient memory to continue the execution of the program (mscorlib) error in SQL Server
Error Message

Cannot execute script. Insufficient memory to continue the execution of the program (mscorlib)

Solution: Use SQLCMD to execute Large TSQL Scripts

SQL Server Management Studio (SSMS) is not always the right option to execute larger script files. Hence it is highly recommended to use SQLCMD utility from command prompt to execute larger files.

How to Start SQLCMD Command Line Utility

1. On the Start menu click Run. In the Open box type cmd, and then click OK to open a Command Prompt window.

2. In the command prompt, type SQLCMD.

3. Press ENTER.

You will now have a trusted connection to the default instance of SQL Server that is running on your computer. 1> is the sqlcmd prompt that specifies the line number. Each time you press ENTER, the number increases by one.

4. Finally to end the sqlcmd session, type EXIT at the sqlcmd prompt.

Let's be connected

Join today; Over 15,000 Microsoft Professionals has subscribed to MyTechMantra.com SQL Server Community News Letter. It's fast, simple, free and secure.
 
Like us on Facebook to receive free updates on what's happening in SQL Server.


How to Run a Script on Standalone SQL Server Instance Using SQLCMD Command Line Utility

sqlcmd -S DATABASESERVERNAME -i "F:/DeploymentScripts/DataPopulation.sql"

How to Run a Script on a Named Instance of SQL Server Using SQLCMD Command Line Utility

sqlcmd -S DATABASESERVERNAME\TESTINSTANCE -i "F:/DeploymentScripts/DataPopulation.sql"

Overview of Different SQLCMD Command Line Options in SQL Server

-S Specifies the instance of SQL Server to which to connect
-i Specify the file path of the input script

Conclusion

It is highly recommended to use SQLCMD command line utility to execute TSQL scripts which are large in size as SQL Server Management Studio will not be able to handle large file for execution




Learn More...





Last Updated On: Oct 27, 2012



Share this Article



Receive Free SQL Server Tips and Keep Learning
Get Free SQL Server Tips




Please leave your Valuable Comment or Let us know how this article helped you: