如何导入大型MS SQL .sql文件? [英] How do you import a large MS SQL .sql file?

查看:88
本文介绍了如何导入大型MS SQL .sql文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用RedGate SQL数据比较并生成.sql文件,因此我可以在本地计算机上运行它。但问题是该文件超过300mb,这意味着我无法复制和粘贴,因为剪贴板将无法处理它,当我尝试在SQL Server Management Studio中打开该文件时,我收到错误关于文件太大。

I use RedGate SQL data compare and generated a .sql file, so I could run it on my local machine. But the problem is that the file is over 300mb, which means I can't do copy and paste because the clipboard won't be able to handle it, and when I try to open the file in SQL Server Management Studio I get an error about the file being too large.

有没有办法运行一个大的.sql文件?该文件基本上包含两个新表的数据。

Is there a way to run a large .sql file? The file basically contains data for two new tables.

推荐答案

从命令提示符启动 sqlcmd

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

只需替换< server> 包含您的SQL框的位置和<您的文件> 以及您的脚本名称。不要忘记,如果您使用的是SQL实例,则语法为:

Just replace <server> with the location of your SQL box and <your file here> with the name of your script. Don't forget, if you're using a SQL instance the syntax is:

sqlcmd -S <server>\instance.

以下是您可以传递sqlcmd的所有参数的列表:

Here is the list of all arguments you can pass 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] 

这篇关于如何导入大型MS SQL .sql文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆