Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create and query linked database servers in SQL Server?

I need to do a join across two different database servers (IPs 10.0.0.50 and 10.0.0.51). What's the best way?

like image 584
Kalid Avatar asked Oct 09 '08 22:10

Kalid


1 Answers

The solution I found:

1) Run a stored proc

exec sp_addlinkedserver    @server='10.0.0.51'

2) Verify that the servers were linked (lists linked servers)

exec sp_linkedservers

3) Run the query using the format

 [10.0.0.51].DatabaseName.dbo.TableName
like image 143
Kalid Avatar answered Oct 12 '22 10:10

Kalid