Link to home
Start Free TrialLog in
Avatar of JayFromPep
JayFromPepFlag for United States of America

asked on

Problem Understanding sp_addlinkedserver

I know this should be straight forward, but cannot get it to work...

Scenario...
2 servers, both running SQL 2005
     Server A
     Server B

I need to link to Server B from Server A to run queries

I am assuming sp_addlinkedserver to be the way to go....so....

I executed the following query from Server A...(obviously the names have been changed to protect the innocent)

exec sp_addlinkedserver
      @server='myFriendlyName',
      @provider='',
      @srvproduct='',
      @datasrc='actualServername',
      @catalog='actualDBName'

Response was "Command(s) completed successfully."

I then try to run a query as such....

SELECT *
FROM myFriendlyName.[actualDBName].[tableName]
WHERE description like '%stuff%'

Intellisense doesnt like it, but I ran it anyway and got the following error....

Msg 208, Level 16, State 1, Line 6
Invalid object name 'myFriendlyName.actualDBName.tableName'.



Response
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

SELECT * FROM myFriendlyName.[actualDBName].dbo.[tableName]WHERE description like '%stuff%'
Avatar of JayFromPep

ASKER

Thanks Angel!

got a bit farther and new error....

Msg 7403, Level 16, State 1, Line 6
The OLE DB provider "" has not been registered.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, new stuff....

Here is what I used to create the linkedserver....


exec sp_addlinkedserver
      @server='myFriendlyName',
      @provider='SQLNCLI',
      @srvproduct='',
      @datasrc='actualServerName\actualDBName'

Worked....but now I am getting login errors....

OLE DB provider "SQLNCLI10" for linked server "myFriendlyName" returned message "Login timeout expired".
OLE DB provider "SQLNCLI10" for linked server "myFriendlyName" 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 65535, Level 16, State 1, Line 0
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
article to start troubleshooting the connection:
https://www.experts-exchange.com/A_1881.html
hmmm....went through the doc, but no luck.  username and password is good (as dbo), remote connections are allowed.

Perhaps there is something else I am forgetting in sp_addlinkedserver command....

exec sp_addlinkedserver
      @server='myFriendlyName',
      @provider='SQLNCLI',
      @srvproduct='',
      @datasrc='actualServer\actualDB',
      @provstr='User ID=username;password=password'