From: Max2006 on
Hi,

I have a big sql file and I need to run it in management studio. The file
size is 248Mb. When I open the file and run it, I receive the following
error:

Cannot execute script.
Exception of type 'System.OutOfMemoryException' was thrown. (mscorlib)

What is the easiest way to run such script and track/see all possible
errors?

Any help would be appreciated,
Max


From: Dan Guzman on
> What is the easiest way to run such script and track/see all possible
> errors?

You might try the command-line SQLCMD utility like the example below. You
can specify a "-o" parameter to write the output to the specified file. I
haven't tried it with very large scripts like yours but I wouldn't expect a
memory limitation as long as the script includes GO batch delimiters to keep
batches to a reasonable size. See the Books Online for details on SQLCMD
usage.

SQLCMD -S MyServer -d MyDatabase -E -i C:\Scripts\MyScriptFile.sql

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

"Max2006" <alanalan1(a)newsgroup.nospam> wrote in message
news:A53C2634-31EA-4C73-8DC0-50552137E4FF(a)microsoft.com...
> Hi,
>
> I have a big sql file and I need to run it in management studio. The file
> size is 248Mb. When I open the file and run it, I receive the following
> error:
>
> Cannot execute script.
> Exception of type 'System.OutOfMemoryException' was thrown. (mscorlib)
>
> What is the easiest way to run such script and track/see all possible
> errors?
>
> Any help would be appreciated,
> Max
>
>

From: Erland Sommarskog on
Max2006 (alanalan1(a)newsgroup.nospam) writes:
> I have a big sql file and I need to run it in management studio. The file
> size is 248Mb. When I open the file and run it, I receive the following
> error:
>
> Cannot execute script.
> Exception of type 'System.OutOfMemoryException' was thrown. (mscorlib)
>
> What is the easiest way to run such script and track/see all possible
> errors?

For that size, you will have to use SQLCMD, a command-line tool. You
can run your file in this way:

SQLCMD -E -d db -i input.sql -o output.txt

You find more information on SQLCMD in Books Online.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx