日期:2014-05-17  浏览次数:20586 次

关于linkedserver的问题
exec   sp_addlinkedserver     '[test]','','SQLOLEDB','192.168.1.22'   
exec   sp_addlinkedsrvlogin   '[test]','false',null,'sa','pwdok' 


我用上面的语句在一台SQL Server2012服务器与另一台SQL Server2008的服务器之间建立Linked server,执行成功,但是执行下面的select 语句提示:“Msg 7202, Level 11, State 2, Line 1
Could not find server 'test' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers." 
我在192.168.1.22的SQL Server中把远程访问都可以,且在SQL Server2012服务器的Managment Studio中直接可以访问SQL Server2008中的数据,请问是什么原因导致上面错误。

说明:在SQL Server2012的服务器中用上述方法对其他的服务器建立linked server可以使用使用。谢谢!


select * FROM [test].ERP2010.dbo.[lxshd]

------解决方案--------------------
链接名和数据库名不是同一码事.

exec sp_addlinkedserver '链接名称',' ','SQLOLEDB','192.168.xx.xxx\SQLEXPRESS2008R2'
exec sp_addlinkedsrvlogin '链接名称','false',NULL,'sa','xxxxxxx'

------解决方案--------------------
引用:
那台电脑只用一个数据库instance,而且名字为MSSQLSERVER,
当我你上述方式建立时(也就是多加了个InstanceName),

则出现如下错误:

OLE DB provider "SQLNCLI11" for linked server "test" returned message "Login timeout expired".
OLE DB provider "SQLNCLI11" for linked server "test" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".
Msg 87, Level 16, State 1, Line 0
SQL Server Network Interfaces: Connection string is not valid [87]. 

说明:远程访问是有打开的,其timeout的值是为0的,IP是可以Ping通的


没看明白是什么意思

这个'192.168.1.22'   是那一台,是2008,还是2012,是在那台服务器上建了到'192.168.1.22'   的连接服务器。

在那一台机器上,执行语句,报错了呢
------解决方案--------------------
引用:
是的,以前用Linked Server很久了,没出现这样的错误
以前是指纯SQL 2008的环境?