SQLServer T-SQL 程序从服务器 1 DB“A”复制表到服务器2 DB“B”
在服务器 A(数据来源)上,我没有获得完整的权限,因为它是托管共享服务器。 即我无法转储数据。
我可以在 SQLServer Manager 中完成这项工作,一次创建一个表的语句,一端使用 linkedServer,另一端使用本地服务器,并提供每一列的名称...唷!任务艰巨!
顺便说一句,许多表都有身份主键。
我想要的(理想情况下)是一个 T-SQL 过程,它将采用一些参数,例如链接服务器的名称、原始表名称和:
1 - 创建目标表
2 - 复制数据
当然,它取决于我以正确的顺序执行此操作并适当尊重外键。
On Server A (Origin of the data) I haven't got full rights because its a hosted shared server.
Namely I can't DUMP data.
I can do the job within SQLServer Manager, creating statements one table at a time, using a linkedServer on one end and the local server on the other and supplying the name of each column... Phew! Tough job!
By the way many tables have Identity primary keys.
What I would like (ideally) is a T-SQL procedure that will take a few bunch of parameters like the name of linked server, the original table name and:
1 - Create the destination table
2 - Copy the data
Of course its up to me to do this in the correct order with due respect to foreign keys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在编写任何代码来管理此镜头之前,您应该检查可能满足您需求的第三方工具。作为一个示例,Red Gate Software 提供了多种实用程序,您可以使用它们复制数据库的结构和然后合并数据。我相信两个 RG 应用程序可以满足您的所有要求。现在,Red gateway 不是免费的,但有完整的试用许可证。可能也有免费/开源工具。
Before writing any code to manage this take you should check out 3rd party tools that may meet your needs. Red Gate Software, as one example, provides several utilities with which you can copy the structure of a database and then merge the data. I believe that all of your requirements are met by two RG applications. Now, Red gate isn't free but does have a full trial license. There are probably free/open source tools out there as well.