SQLCMD 脚本错误 [英] SQLCMD scripting error

查看:15
本文介绍了SQLCMD 脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SQLCMD 运行一个 270 MB 的 .sql 文件.脚本文件 (.sql) 是使用 Red Gate SQL 数据比较同步向导生成的.由于内存不足,我无法从 SSMS 运行它.我登录到服务器并转到命令提示符,它打开命令提示符

<块引用>

C:\Users\USER1>

然后我输入

<代码>>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

但我明白了

<块引用>

Sqlcmd:错误:脚本错误.

我能够使用红门来同步它而不会出错.红门运行同一个 .sql 文件

任何帮助

谢谢

解决方案

我遇到了这个问题,因为一个大脚本做了很多插入.解决方案在另一个答案中结束:定期在文件中插入一个 GO 以便所有内容不是在一项大规模交易中建立起来的.该答案甚至从...一个 RedGate 论坛帖子 获得信息.

由于我使用的是 Linux 并且我的文件是每行一个语句,所以我很容易使用 sed,如这个答案每隔几行添加GO,例如:

<前>$ sed ':循环;n;n;n;n;n;n;n;n;n;一个GOn;b 循环' <bigfile.sql >大文件2.sql

每 10 行插入一个 GO(nsed 脚本中出现的次数),这可能有点矫枉过正.

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

解决方案

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.

这篇关于SQLCMD 脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆