Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out of memory exception when running data-only script

When I run data-only script in SQL Server 2008 R2, it is showing this error:

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

The size of script file is 115MB and it's only data .

When I open this script file, it shows:

Document contains one or more extremely long lines of text.  
These lines cause the editor to respond slowly when you open the file .  
Do you still want to open the file ?

I run schema-only script first and then data-only script .

Is there any way to fix this error ?

like image 932
zey Avatar asked Jul 10 '13 07:07

zey


People also ask

How do I resolve out of memory error in SQL Server?

Open a DAC (Dedicated Administrator Connection) SQL Server provides a dedicated administrator connection (DAC). The DAC allows an administrator to access a running instance of SQL Server Database Engine to troubleshoot problems on the server-even when the server is unresponsive to other client connections.

What happens when SQL Server runs out of memory?

SQL Server doesn't move data from memory (the buffer pool) into tempdb in that way. It uses a "least recently used" caching strategy (in general), so if there is memory pressure, and new data needs to be pulled into memory, SQL Server will kick out the LRU data from the buffer pool to accommodate the new data.


1 Answers

I solved it by using sqlcmd utitlity.

sqlcmd -S "Server\InstanceName" -U "instantName" -P "password" -i FilePathForScriptFile

For example :

sqlcmd -S .\SQLEXPRESS -U sa -P 123 -i D:\myScript.sql
like image 146
zey Avatar answered Nov 02 '22 22:11

zey