如何为 SQL Server 2008 创建链接服务器,其中我们拥有 2000 和 2005 的数据库 [英] How to create the linked server for SQL Server 2008 where we have the database from 2000 and 2005

查看:16
本文介绍了如何为 SQL Server 2008 创建链接服务器,其中我们拥有 2000 和 2005 的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在研究 SQL Server 2000,2005 &2008年,我的要求是,SQL Server 2000 & 中可用的数据库2005 将在 2008 年使用链接服务器提供.

假设我在 SQL Server 2000 中有一个名为 LIVE_2000 的数据库,在 SQL Server 2005 中有一个名为 LIVE_2005 的数据库,有人可以帮我为 LIVE_2000 创建链接服务器吗?code>LIVE_2000 和 LIVE_2005 到 SQL Server 2008?

第一件事这可能吗?

提前致谢...`

解决方案

有一个几种不同的方式您可以在 SQL Server 中创建链接服务器,您可以在 SQL Server Management Studio 中使用 GUI 或通过脚本.

使用 MSDN 上的说明 您可以执行以下操作:

<块引用>

  1. 依次单击开始、所有程序、Microsoft SQL Server 2005 或 Microsoft SQL Server 2008,然后单击 SQL Server Management Studio.

  2. 在连接到服务器"对话框中,指定相应 SQL Server 的名称,然后单击连接".

  3. 在 SQL Server Management Studio 中,双击服务器对象,右键单击链接服务器,然后单击新建链接服务器.

  4. 在新建链接服务器"对话框的常规"页面上的链接服务器"中,输入要链接到的 SQL Server 的完整网络名称.

  5. 在服务器类型下,单击 SQL Server.

  6. 在新建链接服务器"对话框的左窗格中,在选择页面"下,选择安全".

  7. 您需要将本地服务器登录映射到远程服务器登录.在安全"页面的右侧,单击添加"按钮.

  8. 在本地登录下,选择一个本地登录帐户以连接到远程服务器.如果本地登录名也存在于远程服务器上,请选中 Impersonate.或者,如果本地登录将映射到远程 SQL Server 登录,您必须为远程服务器登录提供远程用户名和远程密码.

  9. 在新建链接服务器"对话框的左窗格中,在选择页面"下,选择服务器选项".将 Rpc 和 Rpc Out 参数设置为 True,然后单击 OK.

另一种方法是使用 Transact SQL 编写查询以使用存储过程设置服务器 sp_addlinkedserver

EXEC sp_addlinkedserver@server='你的服务器',@srvproduct='',@provider='SQLNCLI',@datasrc='yourServer\instance1';

任一版本都会设置链接服务器,然后您可以在代码中引用该链接服务器.

Currently I am working on SQL Server 2000,2005 & 2008, my requirement is like, the database available in SQL Server 2000 & 2005 will be available in 2008 using a linked server.

Let's say I have a database in SQL Server 2000 called LIVE_2000 and in SQL Server 2005 it's called LIVE_2005, can someone please help me to create the linked server for LIVE_2000 and LIVE_2005 into SQL Server 2008?

1st thing is this even possible?

Thanks in advance...`

解决方案

There are a few different ways that you can create a linked server in SQL Server you can use the GUI in SQL Server Management Studio or via a script.

Using the instructions on MSDN you can do the following:

  1. Click Start, click All Programs, click Microsoft SQL Server 2005 or Microsoft SQL Server 2008, and then click SQL Server Management Studio.

  2. In the Connect to Server dialog box, specify the name of the appropriate SQL Server, and then click Connect.

  3. In SQL Server Management Studio, double-click Server Objects, right-click Linked Servers, and then click New Linked Server.

  4. In the New Linked Server dialog box, on the General page, in Linked server, enter the full network name of the SQL Serveryou want to link to.

  5. Under Server type, click SQL Server.

  6. In the left pane of the New Linked Server dialog, under Select a page, choose Security.

  7. You will need to map a local server login to a remote server login. On the right side of the Security page, click the Add button.

  8. Under Local Login, select a local login account to connect to the remote server. Check Impersonate if the local login also exists on the remote server. Alternatively, if the local login will be mapped to a remote SQL Server login you must supply the Remote User name and Remote Password for the remote server login.

  9. In the left pane of the New Linked Server dialog, under Select a page, choose Server Options. Set the Rpc and Rpc Out parameters to True, and then click OK.

An alternate way would be to use Transact SQL to write the query to set up the server using the stored procedure sp_addlinkedserver

EXEC sp_addlinkedserver   
   @server='yourServer', 
   @srvproduct='',
   @provider='SQLNCLI', 
   @datasrc='yourServer\instance1';

Either version will set up the linked server that you can then reference in your code.

这篇关于如何为 SQL Server 2008 创建链接服务器,其中我们拥有 2000 和 2005 的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆