SQL Server uses linked servers to remotely fetch data

Source: Internet
Author: User
Tags table name
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!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.