简体   繁体   English

将数据从服务器插入另一台服务器没有链接的sql server 2008

[英]Insert data from a server to another server No linked sql server 2008

I need to copy data using sqlserver 2008 我需要使用sqlserver 2008复制数据

Server1.database.dbo.table to Server1.database.dbo.table到

Server2.database.dbo.table Server2.database.dbo.table

Servers are not linked and cannot link them. 服务器没有链接,无法链接它们。 Cannot use SSIS or any other BI stuff I dont know how to use it,not time to learn. 不能使用SSIS或任何其他BI我不知道如何使用它,而不是时间学习。

My approach 我的方法

Scripted all the data "sql server wizard " "Create Data=true" and then run the script. 脚本化所有数据“sql server wizard”“Create Data = true”然后运行脚本。

my challenge 我的挑战

  1. Some columns might not exists in Server2.database.dbo.table A table Server2.database.dbo.table中可能不存在某些列表

  2. some tables might have the same Primary keys and foreign keys as destination table so Ignore 某些表可能具有与目标表相同的主键和外键,因此忽略

what is the best approach? 什么是最好的方法? Any free tools I can use where I can map columns? 我可以使用哪些免费工具来映射列?

At the moment I am going for a manual script where I have generated the Insert and I have manually worked out the dependency order and commented out the columns that have the same primary keys as destination table. 目前我正在寻找一个手动脚本,我已经生成了Insert,我已经手动设计了依赖顺序,并注释掉了与目标表具有相同主键的列。

Wondering if there is a better way? 想知道是否有更好的方法?

Any suggestions? 有什么建议么? Many thanks 非常感谢

This may be a controversial suggestion, but consider using MS Access as an intermediary. 这可能是一个有争议的建议,但考虑使用MS Access作为中介。

Access will let you link both tables, and write a query to copy from one to the other. Access允许您链接两个表,并编写查询以从一个表复制到另一个表。 It certainly won't be fast, and you may have timeout issues you'll have to address, but you'll get your automatic column-mapping, and if you have MS Office then you'll already have it. 它肯定不会很快,你可能会遇到超时问题,但你会得到自动列映射,如果你有MS Office,那么你已经拥有了它。

I'm NOT suggesting you download all your data to your PC, but I am suggesting that you try linking both tables into an Access database and copying data from one to the other. 我不是建议您将所有数据下载到PC,但我建议您尝试将两个表链接到Access数据库并将数据从一个数据库复制到另一个数据库。

If your target database doesn't have the target tables (though it sounds like it does) you'd have to create them via scripting first, but Access does an adequate job copying data from place to place. 如果您的目标数据库没有目标表(虽然它听起来像这样),您必须首先通过脚本创建它们,但Access可以将数据从一个地方复制到另一个地方。 I call it "the poor man's SSIS". 我称之为“穷人的SSIS”。

It has the advantage that once you've written the queries you need, and perhaps a macro to execute them in order, you can save them, and re-execute them, or tweak them, without having to manipulate a script. 它的优势在于,一旦您编写了所需的查询,并且可能是按顺序执行它们的宏,您就可以保存它们,重新执行它们或调整它们,而无需操作脚本。

SSIS would still be the best solution for your problem , but if you don't have it available or haven't time to learn to use it, I'd look into Access. SSIS仍然是您问题的最佳解决方案 ,但如果您没有它或没有时间学习使用它,我会研究Access。

最后,我最终写的脚本比学习ssis更快,因为它是一次性的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM