How can I copy data records between two instances of an SQLServer database(如何在 SQLServer 数据库的两个实例之间复制数据记录)
问题描述
我需要将一些记录从我们的 SQLServer 2005 测试服务器复制到我们的实时服务器.这是一个平面查找表,因此无需担心外键或其他参照完整性.
I need to copy some records from our SQLServer 2005 test server to our live server. It's a flat lookup table, so no foreign keys or other referential integrity to worry about.
我可以在实时服务器上再次键入记录,但这很烦人.我可以将测试服务器记录和表数据全部导出到 SQL 脚本中并运行它,但我不想覆盖实时系统上存在的记录,只添加到它们.
I could key-in the records again on the live server, but this is tiresome. I could export the test server records and table data in its entirety into an SQL script and run that, but I don't want to overwrite the records present on the live system, only add to them.
如何仅选择我想要的记录并将它们传输或以其他方式进入实时服务器?我们没有 Sharepoint,我知道这可以让我直接在两个实例之间复制它们.
How can I select just the records I want and get them transferred or otherwise into the live server? We don't have Sharepoint, which I understand would allow me to copy them directly between the two instances.
推荐答案
如果你的生产 SQL Server 和测试 SQL Server 可以通信,你可以使用 SQL insert 语句.
If your production SQL server and test SQL server can talk, you could just do in with a SQL insert statement.
首先在您的测试服务器上运行以下命令:
first run the following on your test server:
Execute sp_addlinkedserver PRODUCTION_SERVER_NAME
然后只需创建插入语句:
Then just create the insert statement:
INSERT INTO [PRODUCTION_SERVER_NAME].DATABASE_NAME.dbo.TABLE_NAME (Names_of_Columns_to_be_inserted)
SELECT Names_of_Columns_to_be_inserted
FROM TABLE_NAME
这篇关于如何在 SQLServer 数据库的两个实例之间复制数据记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 SQLServer 数据库的两个实例之间复制数据记录
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
