我的数据库有4GB的sql数据脚本。我想执行它,但SQL Server Management Studio允许我这样做,因为它是一个非常大的文件。
所以我想把这个文件分成更小的文件,以便我可以执行它。我用谷歌搜索了它,但没有得到任何好的解决方案。我还使用HJSplit来分割文件,但只有第一个分割文件的格式正确,但其他格式不正确,因为它们无法在SQL查询接口中执行。
请帮助我们如何使用或不使用拆分执行此.sql
文件?
答案 0 :(得分:3)
使用sqlcmd工具执行文件..
sqlcmd -S myServer\instanceName -i C:\myScript.sql
或
sqlcmd -S <server> -i C:\<your file here>.sql -o
只需替换SQL框的位置和脚本的名称即可。不要忘记,如果您使用的是SQL实例,语法是: sqlcmd -S \ instance。
以下是您可以传递sqlcmd的所有参数的列表:
Sqlcmd [-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 screen width]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-c cmdend] [-L[c] list servers[clean output]]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
[-u unicode output] [-r[0|1] msgs to stderr]
[-i inputfile] [-o outputfile] [-z new password]
[-f | i:[,o:]] [-Z new password and exit]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-b On error batch abort]
[-v var = "value"...] [-A dedicated admin connection]
[-X[1] disable commands, startup script, enviroment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]