Triple K
Triple K

Reputation: 399

SELECT Query between two different servers

I want to pull out data from different tables from different servers. I took a query at V5\SQL2014 Server and run these following to connect to V5_27\SQL2005 Server

EXEC sp_addlinkedserver 
@server= 'V5_27\SQL2005',
@srvproduct='V5_27\SQL2005',
@provider='SQLNCLI', 
@datasrc='tcp:0.0.0.0'

EXEC sp_addlinkedsrvlogin
@useself='FALSE',
@rmtsrvname='V5_27\SQL2005',
@rmtuser='sa',
@rmtpassword='123'

SELECT * FROM Stk006,[V5_27\SQL2005]..[TESTACC].Stk006

It shows me following errors.

OLE DB provider "SQLNCLI11" for linked server "V5_27\SQL2005" returned message "Login timeout expired".

OLE DB provider "SQLNCLI11" for linked server "V5_27\SQL2005" 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 10049, Level 16, State 1, Line 22 TCP Provider: The requested address is not valid in its context.

  1. User and Password are not wrong.
  2. Allow remote is enabled in both servers.
  3. TCP/IP and Named Pipes are enabled in both servers.

Please help me, thanks!

Upvotes: 0

Views: 15571

Answers (1)

Triple K
Triple K

Reputation: 399

Thanks everyone, I found a solution for my problem.

You can check the solution link here or do below steps.

  1. Try to create a linkServer , Object Explorer -> Server Objects -> Linked Servers (Right click and create new)

enter image description here

  1. Configure Settings

Enter your Server Name enter image description here

Login with sa and password

enter image description here

  1. Then Test Connection of it.

enter image description here

  1. Enjoy your query.

select lc.t2 as 'Local Stock Code', ext.t2 as 'External Stock Code' from Stk001 lc, [V5_27\SQL2005].[TESTACC].[dbo].[STK001] ext

Upvotes: 1

Related Questions