如何在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.

如何只选择我想要的记录,并将它们传输或以其他方式进入实时服务器?

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服务器和测试SQL服务器可以谈话,你可以只使用SQL插入语句。

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

然后只需创建insert语句:

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