Search code examples
sql-server-2008linked-server

Linked Server Connection Error


I created a linked server to my machine to query from other server using this script.

EXEC sp_addlinkedserver 
    @server = N'serverdatabase\vtidbserver', 
    @provider = N'SQLOLEDB', 
    @datasrc = N'VTI_FIS', 
    @srvproduct=''
EXEC sp_addlinkedsrvlogin 
    @rmtsrvname=N'serverdatabase\vtidbserver',
    @useself=N'False',
    @locallogin=NULL,
    @rmtuser=N'vtidbadmin',
    @rmtpassword='vallacar@654321'

now the script successfully execute but when it try to query, this is the error message that i got:

OLE DB provider "SQLNCLI10" for linked server "serverdatabase\vtidbserver" returned message "Login timeout expired".
OLE DB provider "SQLNCLI10" for linked server "serverdatabase\vtidbserver" 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 53, Level 16, State 1, Line 0
Named Pipes Provider: Could not open a connection to SQL Server [53]. 

But when using management studio i can connect to the server successfully. Need to help this problem, TIA


Solution

  • I suppose it is another MS SQL server. If it is, you don't have to use provider, only have to specify product.

    exec master.dbo.sp_addlinkedserver @server = N'TEST', @srvproduct=N'SQL Server'
    

    Hope that helps.