Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLCMD scripting error

Tags:

sqlcmd

i am using SQLCMD to run a .sql file which is 270 MB. The script file (.sql) was generated using Red Gate SQL Data Compare synchronization wizard. I cannot run it from SSMS because of insufficient memory. I log into the server and go to command prompt and it opens up command prompt

C:\Users\USER1>

then i type in

> C:\Users\USER1>SQLCMD -U sa -P PWD -d DATA_FEAT -i F:\SYNC\DATA-DATA_FEAT-20140709.sql -o F:\SYNC\DATA-DATA_FEAT-20140709result.txt

but i get

Sqlcmd: Error: Scripting error.

i am able to use Red gate to synchronize it without error. Red gate runs the same .sql file

Any Help

Thanks

like image 607
user176047 Avatar asked Jul 10 '14 00:07

user176047


People also ask

How can I tell if SQLCMD is working?

You could try to execute sqlcmd.exe -? in a process in your C# app - if it works, then SQLCMD is present - if not, it'll tell you something like "file not found" or "command invalid" or something ....

What is SQLCMD used for?

The sqlcmd utility is a command-line utility for ad hoc, interactive execution of Transact-SQL statements and scripts and for automating Transact-SQL scripting tasks.


Video Answer


1 Answers

I ran into this with a big script doing a lot of inserts. The solution was over in this other answer: Insert a GO periodically in the file so that everything wasn't being built up in one massive transaction. That answer even got the info from...a RedGate forum thread.

Since I'm using Linux and my file was one-statement-per-line, it was quite easy for me to use sed as outlined in this answer to add GO every few lines, e.g.:

$ sed ': loop; n; n; n; n; n; n; n; n; n; a GO
n; b loop' < bigfile.sql > bigfile2.sql

That inserts a GO every 10 lines (the number of times n appears in the sed script), which is probably overkill.

like image 73
T.J. Crowder Avatar answered Oct 18 '22 20:10

T.J. Crowder