I have two machines , each one contains SQL Server + different instance/database + different IP/port ( as you know )
I want to load data from machine A to Machine B by executing a T-SQL procedure on B. I use Windows Authentication as authentication method.
I read about sp_addlinkedserver but I couldn't execute it successfully .
Edit:
I hope to see an exeample of using sp_addlinkedserver with different servers that use windows authentication ads auth method
I found the solution :-) , it was related to something called Security Account Delegation and mapping a SQL server login to the linked serve
for more information read the first answer from here.
TSQL code:
-- drop old things
-- EXEC sp_droplinkedsrvlogin myLinkedServer, null
-- drop old linked server if it is there
-- EXEC sp_dropserver 'myLinkedServer'
EXEC sp_addlinkedserver @server='myLinkedServer',
@srvproduct=N'',
@provider='SQLNCLI',
@datasrc='10.10.11.13', -- server ip try 10.16.11.13\Your_Instance_Name
@provstr='User ID=testuser;password=Aa123456' -- you can add Integrated Security=SSPI;
-- debugging to check if the linked server is created or not
select * from sys.servers where name = 'myLinkedServer';
-- map a SQL server login to the linked server
EXEC sp_addlinkedsrvlogin 'myLinkedServer', 'false', NULL, 'testuser', 'Aa123456'
-- display some data
select * from myLinkedServer.[dev_master].[dbo].[attendanceReport]
It was tested using SQL Server 2005 + 2008 , and it works successfully.