如何在 SQLServer 数据库的两个实例之间复制数据记录

How can I copy data records between two instances of an SQLServer database(如何在 SQLServer 数据库的两个实例之间复制数据记录)
本文介绍了如何在 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 数据库的两个实例之间复制数据记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)