Getting error while running 50 MB script on SQL Server 2008 R2

Vikrant More picture Vikrant More · Jul 3, 2012 · Viewed 58k times · Source

I am using SQL Server 2008 R2, I have a script to update the DB, that script is approx 50 MB in size and contains some about 800,000 lines.

Error:

TITLE: Microsoft SQL Server Management Studio

Cannot execute script.

ADDITIONAL INFORMATION:

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

Can somebody please help me to run this script without getting this error?

Answer

user1293068 picture user1293068 · Jul 3, 2012

use the command-line tool SQLCMD which is much leaner on memory. It is as simple as:

SQLCMD -d <database-name> -i filename.sql

You need valid credentials to access your SQL Server instance or even to access a database