为选定的记录生成插入脚本? [英] Generate insert script for selected records?

查看:56
本文介绍了为选定的记录生成插入脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下数据的表:

I have a table with the following data:

Pk_Id  ProductName           Fk_CompanyId       Price
------------------------------------------------------
1      AMX                   1                  10.00
2      ABC                   1                  11.00
3      APEX                  1                  12.00
4      AMX                   1                  10.00
5      ABC                   1                  11.00
6      APEX                  1                  12.00
7      AMX                   2                  10.00
8      ABC                   2                  11.00
9      APEX                  2                  12.00

I要生成用于迁移Fk_CompanyId为1的记录的插入脚本。

I want to generate Insert script for migrating records whose Fk_CompanyId is 1.

有一个插入脚本选项可以为所有记录生成脚本,但是我想过滤一些记录以迁移到另一个数据库。

There is an insert script option to generate script for all records but I want to filter some records to migrate to another database.

推荐答案

如果使用的是SQL Management Studio,则可以右键单击数据库名称,然后选择
Tasks> Import / Export data,然后按照向导进行操作。

其中一个步骤称为指定表复制或查询,其中可以选择编写查询以指定要传输的数据,因此您只需指定以下查询即可:

If you are using the SQL Management Studio, you can right click your DB name and select Tasks > Import/Export data and follow the wizard.
one of the steps is called "Specify Table Copy or Query" where there is an option to write a query to specify the data to transfer, so you can simply specify the following query:

select * from [Table] where Fk_CompanyId = 1

这篇关于为选定的记录生成插入脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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