T-SQL Tip: How to Create a Simple Linked Server Between SQL Server Instances

--The Entire Operation Takes Place on the Local Instance

USE [master]

--Create the linked server object
EXEC master.dbo.sp_addlinkedserver 
@server = N'[LinkedServerName]', 

 --Set up the user mapping between local and remote instances
EXEC master.dbo.sp_addlinkedsrvlogin 

--Example of querying a remote table
select * from [LinkedServerName].[Database_Name].[Schema_Name].[Table_Name]

For more info, check out the following links:

Labels: ,