I am trying to restore database data using the following command from a large .sql
file
我试图从大型.sql文件中使用以下命令还原数据库数据
Type myfile.sql | sqlsmd –S server –U username –P password
I get the following error:
我收到以下错误:
Sqlcmd: Error: Scripting error.
I am unable to open the file, there is not enough memory.
我无法打开文件,内存不足。
3 个解决方案
#1
SQLCMD has a "-i" inputfile parameter as well - I'd recommend using that. "Type"-ing the file and piping your output into SQLCMD is a hackish way to run the file, especially when the command line includes native support for reading from a file. Try this:
SQLCMD也有一个“-i”输入文件参数 - 我建议使用它。 “输入”文件并将输出管道输入SQLCMD是一种运行文件的hackish方式,尤其是当命令行包含从文件读取的本机支持时。试试这个:
sqlcmd –S server –U username –P password -i MyFile.sql
#2
you could try using isql which has a -i input file option - that loses the nasty
您可以尝试使用具有-i输入文件选项的isql - 这会丢失令人讨厌的内容
Type myfile.sql |
You don't say which version of Sql you're using, but you could probably run your file in using DTS/SSIS, if you go with that approach you'll be able to turn on logging and actually see which line(s) fail, and set a threshold for an acceptable number of failing lines.
你没有说你正在使用哪个版本的Sql,但你可能使用DTS / SSIS运行你的文件,如果你采用这种方法,你将能够打开日志并实际看到哪一行失败,并为可接受数量的失败行设置阈值。
Another way is to use management studio to open the file and then execute it.
另一种方法是使用management studio打开文件然后执行它。
#3
Try this
@echo Server: %1
@echo Database: %2
@echo User: %3
@echo Password: %4
set ISQLCMD=SQLCMD -S %1 -d %2 -U %3 -P %4 -m1 -i
#1
SQLCMD has a "-i" inputfile parameter as well - I'd recommend using that. "Type"-ing the file and piping your output into SQLCMD is a hackish way to run the file, especially when the command line includes native support for reading from a file. Try this:
SQLCMD也有一个“-i”输入文件参数 - 我建议使用它。 “输入”文件并将输出管道输入SQLCMD是一种运行文件的hackish方式,尤其是当命令行包含从文件读取的本机支持时。试试这个:
sqlcmd –S server –U username –P password -i MyFile.sql
#2
you could try using isql which has a -i input file option - that loses the nasty
您可以尝试使用具有-i输入文件选项的isql - 这会丢失令人讨厌的内容
Type myfile.sql |
You don't say which version of Sql you're using, but you could probably run your file in using DTS/SSIS, if you go with that approach you'll be able to turn on logging and actually see which line(s) fail, and set a threshold for an acceptable number of failing lines.
你没有说你正在使用哪个版本的Sql,但你可能使用DTS / SSIS运行你的文件,如果你采用这种方法,你将能够打开日志并实际看到哪一行失败,并为可接受数量的失败行设置阈值。
Another way is to use management studio to open the file and then execute it.
另一种方法是使用management studio打开文件然后执行它。
#3
Try this
@echo Server: %1
@echo Database: %2
@echo User: %3
@echo Password: %4
set ISQLCMD=SQLCMD -S %1 -d %2 -U %3 -P %4 -m1 -i