如何在 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
相关文章