Jac*_*ack 229 sql sql-server import
我使用RedGate SQL数据比较并生成.sql文件,因此我可以在本地计算机上运行它.但问题是该文件超过300mb,这意味着我无法复制和粘贴,因为剪贴板将无法处理它,当我尝试在SQL Server Management Studio中打开该文件时,我收到错误关于文件太大了.
有没有办法运行一个大的.sql文件?该文件基本上包含两个新表的数据.
Ray*_*sen 420
从命令提示符,启动sqlcmd:
sqlcmd -S <server> -i C:\<your file here>.sql
Run Code Online (Sandbox Code Playgroud)
只需替换<server>SQL框的位置和<your file here>脚本的名称即可.不要忘记,如果您使用的是SQL实例,则语法为:
sqlcmd -S <server>\instance.
Run Code Online (Sandbox Code Playgroud)
以下是您可以传递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, environment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]
Run Code Online (Sandbox Code Playgroud)
小智 61
我有完全相同的问题,并且已经挣扎了一段时间,然后终于找到了解决方案,即将-a参数设置sqlcmd为更改其默认数据包大小:
sqlcmd -S [servername] -d [databasename] -i [scriptfilename] -a 32767
Run Code Online (Sandbox Code Playgroud)
Sya*_*mar 13
执行以下命令
sqlcmd -S 'your server name' -U 'user name of server' -P 'password of server' -d 'db name'-i script.sql
小智 7
我正在使用MSSQL Express 2014,但没有一个解决方案适合我.他们都只是崩溃了SQL.因为我只需要运行一个带有许多简单插入语句的一个脚本脚本,我通过编写一个小控制台应用程序作为最后的手段:
class Program
{
static void Main(string[] args)
{
RunScript();
}
private static void RunScript()
{
My_DataEntities db = new My_DataEntities();
string line;
System.IO.StreamReader file =
new System.IO.StreamReader("c:\\ukpostcodesmssql.sql");
while ((line = file.ReadLine()) != null)
{
db.Database.ExecuteSqlCommand(line);
}
file.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
194787 次 |
| 最近记录: |