我有一个非常大的脚本(大约1GB)和UPDATE
语句。像
UPDATE Table1 SET Col1 = 'Some text 1' WHERE ID = 1
UPDATE Table1 SET Col1 = 'Some text 2' WHERE ID = 2
-- and so on
执行此脚本的最佳方法是什么?我想我不能简单地在文本编辑器中打开它并运行查询...
另外感谢。
已更新
我需要在远程SQL Server实例上运行此脚本。
答案 0 :(得分:4)
使用osql实用程序Reference
执行它示例:
osql -E -i C:\MyFolder\MyScript.sql -o C:\MyFolder\MyOutput.rpt
您也可以输入以供参考:
osql -?
usage: osql [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w columnwidth]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-L list servers] [-c cmdend] [-D ODBC DSN name]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-n remove numbering] [-m errorlevel]
[-r msgs to stderr] [-V severitylevel]
[-i inputfile] [-o outputfile]
[-p print statistics] [-b On error batch abort]
[-X[1] disable commands [and exit with warning]]
[-O use Old ISQL behavior disables the following]
<EOF> batch processing
Auto console width scaling
Wide messages
default errorlevel is -1 vs 1
[-? show syntax summary]
对于远程服务器,但您需要在计算机上安装sql实用程序,您可以运行它。
osql -S <instance name> -U <username> -P <password> -i C:\MyFolder\MyScript.sql -o C:\MyFolder\MyOutput.rpt
答案 1 :(得分:0)
这对你有帮助,对我来说非常好