What is a linked server in SQL Server, and why would you set one up?
Short answer
A linked server lets your SQL Server instance connect to and query data from another database server, whether it is another SQL Server instance or a different type of database entirely, allowing you to write queries that combine data from multiple separate database servers as if…
Advertisement
AModel answer
A linked server lets your SQL Server instance connect to and query data from another database server, whether it is another SQL Server instance or a different type of database entirely, allowing you to write queries that combine data from multiple separate database servers as if they were part of the same system.
EXEC sp_addlinkedserver
@server = 'RemoteServer',
@srvproduct = '',
@provider = 'SQLNCLI',
@datasrc = 'RemoteServerAddress';Real-world example
A company with separate databases for sales and inventory sets up a linked server so their reporting team can write a single query combining data from both systems without manually exporting and merging data by hand.
Likely follow-ups
- What types of databases can a linked server connect to besides SQL Server?
- Does setting up a linked server require special permissions?
Related topics