server| Server | links | data
As a recently developed query system, basically in other servers, so the local server design in the middle, to save data from the remote server!
One way is by OPENDATASOURCE to read data remotely!
SELECT *
From OpenDataSource (
' SQLOLEDB ',
' Data source=servername; User Id=myuid; Password=mypass '
). Northwind.dbo.Categories
But remote server can not confirm, more trouble, if you want to implement, only the connection information to the server, through dynamic SQL (exec or sp_excute_sql to achieve the purpose)
Another way is to add a linked server,
sp_addlinkedserver @server = N ' linked server name ',
@srvproduct = N ',
@provider = N ' SQLOLEDB ',
@datasrc = N ' remote server IP ',
Add Linked server login
sp_addlinkedsrvlogin [@rmtsrvname =] ' Linked server name '
[, [@useself =] ' false ']
[, [@locallogin =] ' local sign-in name ']
[, [@rmtuser =] ' telnet name '
[, [@rmtpassword =] ' remote password ']
This allows access to the remote server through the SQL
SELECT * from linked server name. Remote Data name. Remote Table name
Do not have to manage the remote server address login name, can only link server name, unchanged, when the formal, can not modify the program!