Tuesday, May 15, 2012

Using Linked Servers in SQL Server

When you work with software you have in mind that everything is interconnected, even more when you're talking about servers. And things could get really ugly if you need to make queries and see that a part of your information is located in another server.

Fortunately, Microsoft SQL Server helps us in this situation giving us a feature that allows us to reference a different server and use it to make queries against it.

So, let's open SQL Server Management Studio, get in to the server and go to "Linked Servers" folder located in "Server Objects".


Now, you have to create a new linked server by using the right-click button and the appropriate option.


In this ocasion, just type the linked server name on the textbox and select the type of this, keep in mind that you can connect to other sources different from SQL Server.


After you do this, on the "Security" section you hace to specify the mapping between users and for the rest of users you'll have to select the connection mode.


Once you finish this, you will be able to query the data from your new linked server, this will appear under the "Linked Servers" folder. Since now you can build this kind of queries:

SELECT * FROM TEMP.CATALOGTEMP.DBO.TEMPTABLE

That's all.


No comments:

Post a Comment