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
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 ....
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With