Joining Tables from multiple SQL Server databases located on separate severs

前端 未结 4 1202
南笙
南笙 2021-01-19 03:52

What is the recommended way of joining SQL Server database tables located on databases which are on different servers?

All databases will be on the same network.

相关标签:
4条回答
  • 2021-01-19 04:24

    Linked Servers are the way to go for simple/low end implementation.

    If you are looking at quite a high end platform/architecture then you may want to look at SQL Server Federated Databases.

    0 讨论(0)
  • 2021-01-19 04:31

    Linked servers work - but have some issues that make me try to avoid them:

    1. Over time they make managing your environment, from a high level, a nightmare. Servers come and go, get upgraded and so on, and that gets really sketchy when you have hundreds of queries lurking around with servernames hardcoded in (think "... join myRetriringServer.someDatabase.dbo.importantData ..." ). Aliases help, but they are a hassle IMHO. It's an example of problematic tight coupling.

    2. Performance can be a very serious problem because cross-server queries of any complexity don't optimize, and you'll find the servers frequently resort on-the-fly copies of whole tables over the wire. (Joe ++)

    If you're in a really small environment, it works OK. For bigger environments, I much prefer moving slowly-changing data around with SSIS, and then working to co-locate rapidly changing / dependent data on the same server for performance.

    0 讨论(0)
  • 2021-01-19 04:39

    You can set the servers up as linked servers:

    http://www.sqlservercentral.com/articles/Video/66413/

    You will then be able to run queries that reference the different databases.

    0 讨论(0)
  • 2021-01-19 04:43

    You can use linked servers, though there can be some funky things with query execution in some cases. It depends on the queries you're running.

    You can alternately set up replication from the other databases to a single server, and run all queries on that one server.

    0 讨论(0)
提交回复
热议问题