When I am trying to run a script of 300mb on SQL Server 2012 I am getting this issue
Cannot execute script: Insufficient memory to continue the execution of the program (mscorlib)
here is the image
How to resolve this issue to run script(insufficient memory) in sql server? I need to restore my database using this script
You can resolve "Cannot execute script: Insufficient memory Error" by executing your scripts using cmd instead of SQL server.
To run your script in command-line tool using SQLCMD
sqlcmd -S <ComputerName>\<InstanceName> -d <DatabaseName> -i <MyScript.sql>
If credentials are required
sqlcmd -S <ComputerName>\<InstanceName> -U <username> -P <password> -d <DatabaseName> -i <MyScript.sql>?
Ensure that your network account has sufficient permissions to access both SQL Server instance and the specific database you intend to restore.
Sometimes, due to the large size of the script and data, we may encounter this type of error. Server needs sufficient memory to execute and give the result.
Another solution is to simply increase the Maximum Server Memory value in server properties. To edit this setting, right click on server name and select Properties > Memory tab.
After increasing the value from 1024MB to 2048MB, you can try to run scripts again, and it should throw the error.