Add a linked server with Enterprise Manager or Transact-SQL
Enterprise Manager Linked Server
You can use either Enterprise Manager or Transact-SQL to add a linked server. Some points to remember when adding linked servers:
With one exception (the OPENROWSET function that you will see later in this module), you need to add a linked server whenever you wish to access data that is on a remote server.
A linked server must be able to communicate with an OLE DB data source, such as SQL Server 2012.
You need to add a linked server only once. From then on, you simple write your queries against the linked server.
Both servers need to set up the lines of communication, and therefore must add each other to their list of linked servers.
Using Enterprise Manager
To use Enterprise Manager to add a linked server, follow the steps in the simulation below: < Remember that, to complete the connection, you will need to perform these steps on the server that you are you linking to.
The second way to add a linked server is by using Transact-SQL code. To use Transact-SQL code, use the sp_addlinkedserver system stored procedure. To add a SQL Server 2012 server, simply use this syntax:
Dropping a linked server
If you wish to remove the linked server, use the sp_dropserver system stored procedure, passing it the name of the server you wish to drop.
You must use an extended syntax if you wish to use an OLE DB provider for any data source other than SQL Server. Refer to SQL Server Books Online for more information about this syntax.
Accessing a Local SQL Server Database
When you access a second database on a single server, the same SQL Server engine processes the data.
Therefore, although the data is outside the local database, the query is not actually a distributed query.
A SQL Server query may access another database on the same server by referring to the remote stored
procedure, table, or view using the three parts of the four-part name. The complete four-part name is
the full address of the object:
Because the database is on the same server, the server name is optional. Typically, the tables are in the
database owner schema (dbo). If that’s the case, then dbo can be assumed:
SELECT LastName, FirstName
The schema can be assumed to be dbo and ignored by just leaving the schema empty. The following
query is functionally equivalent to the previous query, but does not specify the schema:
Server Objects: Details objects such as backup devices and provides a list of linked servers, where one server is connected to another remote server
In the next lesson, you will learn how to log on to the server using a remote login.