5

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 ?

1

3 Answers 3

13

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
Sign up to request clarification or add additional context in comments.

Comments

1

Zey's answer was helpful for me, but for completion:

If you want to use Windows Authentication just omit the user and password.

And don't forget the quotes before and after the path if you have spaces.

sqlcmd -S .\SQLEXPRESS -i "C:\Users\Stack Overflow\Desktop\script.sql"

Comments

0

If you're logged into the domain with the correct privileges and there's only one instance running, you also do not have to provide the above user/pw/instance command args. I was able to just execute:

sqlcmd -i myfile.sql

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.