如何将4GB .sql文件溢出到较小的文件中

时间:2021-09-12 17:19:32

I have a 4GB sql data script of my database. I want to execute it but SQL Server Management Studio does allow me to do it because it's a very big file.

我有一个4GB的数据库sql数据脚本。我想执行它,但SQL Server Management Studio允许我这样做,因为它是一个非常大的文件。

So I want to split this file into smaller files so that I can execute it. I have googled it but didn't get any good solutions. I have also used HJSplit to split the files but only first split file is in correct format but others are not in correct format due to which can not be execute in SQL query Interface.

所以我想将这个文件拆分成更小的文件,以便我可以执行它。我用谷歌搜索了它,但没有得到任何好的解决方案。我还使用HJSplit来分割文件,但只有第一个分割文件的格式正确,但是其他格式不正确,因为它们无法在SQL查询接口中执行。

Please help me guys how can I execute this .sql file with data with or without splitting?

请帮助我们如何执行此.sql文件与数据有或没有拆分?

1 个解决方案

#1


3  

use the sqlcmd tool to execute the file..

使用sqlcmd工具执行文件..

sqlcmd -S myServer\instanceName -i C:\myScript.sql

or

sqlcmd -S <server> -i C:\<your file here>.sql -o

Just replace with the location of your SQL box and with the name of your script. Don't forget if you're using a SQL instance the syntax is: sqlcmd -S \instance.

只需替换SQL框的位置和脚本的名称即可。不要忘记,如果您使用的是SQL实例,则语法为:sqlcmd -S \ instance。

Here is the list of all arguments you can pass sqlcmd:

以下是您可以传递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]

#1


3  

use the sqlcmd tool to execute the file..

使用sqlcmd工具执行文件..

sqlcmd -S myServer\instanceName -i C:\myScript.sql

or

sqlcmd -S <server> -i C:\<your file here>.sql -o

Just replace with the location of your SQL box and with the name of your script. Don't forget if you're using a SQL instance the syntax is: sqlcmd -S \instance.

只需替换SQL框的位置和脚本的名称即可。不要忘记,如果您使用的是SQL实例,则语法为:sqlcmd -S \ instance。

Here is the list of all arguments you can pass sqlcmd:

以下是您可以传递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]