将 SQL Server 中的数据导出为 INSERT INTO

2022-01-09 00:00:00 sql data-migration insert sql-server

我正在使用 SQL Server 2008 Management Studio 并且有一个表我想迁移到不同的数据库服务器.

I am using SQL Server 2008 Management Studio and have a table I want to migrate to a different db server.

是否有任何选项可以将数据导出为插入到 SQL 脚本中?

Is there any option to export the data as an insert into SQL script??

推荐答案

在对象资源管理器的 SSMS 中,右键单击数据库,右键单击并选择任务",然后选择生成脚本".

In SSMS in the Object Explorer, right click on the database, right-click and pick "Tasks" and then "Generate Scripts".

这将允许您为单个或所有表生成脚本,其中一个选项是脚本数据".如果将其设置为 TRUE,向导将为您的数据生成带有 INSERT INTO () 语句的脚本.

This will allow you to generate scripts for a single or all tables, and one of the options is "Script Data". If you set that to TRUE, the wizard will generate a script with INSERT INTO () statement for your data.

如果使用 2008 R2 或 2012 则称为其他名称,请参见下面的截图

选择要编写脚本的数据类型",可以是仅数据"、架构和数据"或仅架构" - 默认).

Select "Types of Data to Script" which can be "Data Only", "Schema and Data" or "Schema Only" - the default).

然后在 Codeplex(包括源代码)上有一个SSMS Addin"包,它几乎承诺相同的功能和更多功能(如快速查找等)

And then there's a "SSMS Addin" Package on Codeplex (including source) which promises pretty much the same functionality and a few more (like quick find etc.)

相关文章