且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 SQL Server 2012 数据库获取 .sql 文件

更新时间:2022-11-24 22:19:12

如果您只想生成一个 .sql 脚本,您可以通过在对象资源管理器中右键单击数据库并选择任务 > 生成脚本来实现:

If you just want to generate a .sql script you can do this by right-clicking the database in Object Explorer and choosing Tasks > Generate Scripts:

然后你可以选择数据库和所有对象,也可以只选择你想要的表:

Then you can select database and all objects, or you can select just the table you want:

然后选择一个位置,并确保在继续之前进入高级:

Then select a location, and be sure to go into Advanced before continuing:

在高级下,至少,将脚本的数据类型更改为架构和数据"(如果您这样做而不是正确备份的原因是因为您需要在 SQL 之前将数据导入数据库Server 2012,您可能应该将目标服务器版本选项更改为您的目标版本):

Under advanced, at the very least, change types of data to script to "Schema and Data" (if the reason you are doing this rather than a proper backup is because you need to import the data into a database earlier than SQL Server 2012, you should probably change the target server version option to whatever version you're targeting):

如果您在 Management Studio 中没有该选项,则您可能仍在运行客户端工具的 RTM 版本.从 SP1 开始,全部功能终于免费提供.在此处下载最新版本 - SP2:

If you don't have that option in Management Studio, you are probably still running the RTM version of the client tools. Full functionality has finally been made free as of SP1. Download the most recent version - SP2 - here:

http://www.microsoft.com/en-us/download/details.aspx?id=43351

(您需要 SQLManagementStudio 文件之一.)

(You want one of the SQLManagementStudio files.)