本文介绍了更新来自不同服务器的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用来自服务器A的数据更新另一个服务器B中的表的最佳方法是什么?

我尝试使用servername.databasename.databaseowner.tablename

但是它不起作用:将服务器添加到sys.servers的sp_addlinksever".还有另一种方法可以执行此操作,而无需执行该过程.也许使用C#?

What is the best way to update a table which is in another server B with data from server A?

I tried to use the servername.databasename.databaseowner.tablename

But it doesnot work: "sp_addlinksever to add the server to sys.servers". There is another way to do this without the need of doing that procedure; maybe with C#?

推荐答案

SqlCommand cmdServer1 = new SqlCommand("query", new SqlConnection("first server con string"));

SqlCommand cmdServer2 = new SqlCommand("query", new SqlConnection("Second server con string"));



这样,您的应用程序可以根据它们各自的连接字符串分别连接到两个服务器.

注意:您不应复制/粘贴上面的代码,因为我刚刚向您显示了代码,因此有改进的机会.

:)



By this way your application can separately connect to two server based on their respective connectionstrings.

Note : you should not copy / paste the code above, as I just showed you the code and there is chance for betterment.

:)



SELECT a.* FROM OPENROWSET('MSDASQL.1', 'DRIVER=SQL Server;SERVER=192.168.2.2;UID=sa;PWD=;DATABASE=CBOS',
'SELECT * FROM MASTER') as a


这篇关于更新来自不同服务器的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:49