Selecting data from two different servers in SQL Server

后端 未结 15 1702

How can I select data in the same query from two different databases that are on two different servers in SQL Server?

15条回答
  •  情歌与酒
    2020-11-22 07:54

    Querying across 2 different databases is a distributed query. Here is a list of some techniques plus the pros and cons:

    1. Linked servers: Provide access to a wider variety of data sources than SQL Server replication provides
    2. Linked servers: Connect with data sources that replication does not support or which require ad hoc access
    3. Linked servers: Perform better than OPENDATASOURCE or OPENROWSET
    4. OPENDATASOURCE and OPENROWSET functions: Convenient for retrieving data from data sources on an ad hoc basis. OPENROWSET has BULK facilities as well that may/may not require a format file which might be fiddley
    5. OPENQUERY: Doesn't support variables
    6. All are T-SQL solutions. Relatively easy to implement and set up
    7. All are dependent on connection between source and destionation which might affect performance and scalability

提交回复
热议问题