且构网

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

如何将DB中的标识插入表中的数据插入到没有标识插入/约束的另一个DB中?

更新时间:2023-11-30 21:41:16

如果表结构相同,只需用向导创建脚本,使用以下方式



选项1 - 右键单击​​要复制的数据库

- 选择任务> '生成脚本'

- '选择特定数据库对象'

- 检查'表'

- 标记'保存到新查询窗口'

- 点击'高级'

- 将'脚本数据类型'设置为'架构和数据'

- 下一步,下一步>
- 您现在可以在新数据库上运行生成的查询。



选项2

- 右键单击​​数据库你要复制

- '任务'> '导出数据'

- 下一步,下一步

- 选择要将表格复制到的数据库

- 标记'从一个或多个复制数据表格或视图'

- 选择要复制的表格

- 完成
If the table structure is same, simple create a scripts with wizard, use following ways

Option 1 - Right click on the database you want to copy
- Choose 'Tasks' > 'Generate scripts'
- 'Select specific database objects'
- Check 'Tables'
- Mark 'Save to new query window'
- Click 'Advanced'
- Set 'Types of data to script' to 'Schema and data'
- Next, Next
- You can now run the generated query on the new database.

Option 2
- Right click on the database you want to copy
- 'Tasks' > 'Export Data'
- Next, Next
- Choose the database to copy the tables to
- Mark 'Copy data from one or more tables or views'
- Choose the tables you want to copy
- Finish