[英]How to run T-SQL in another DB server?
I want to select some data form another database in another server. 我想从另一个服务器中的另一个数据库中选择一些数据。
What I know is add a Linked Server, and run the T-SQL. 我所知道的是添加一个链接服务器,然后运行T-SQL。
Is this way is a good choice, or is there any other way to run SQL in other database servers? 这是一个不错的选择,还是有其他方法可以在其他数据库服务器中运行SQL?
thanks. 谢谢。
Adding a linked server is fine. 添加链接服务器很好。
You will then probably use the 4 part naming convention 然后,您可能会使用4部分命名约定
select * from [server].[database].[Owner or Schema].[tablename]
Or you could look at OPENROWSET (Transact-SQL) 或者您可以查看OPENROWSET(Transact-SQL)
Includes all connection information that is required to access remote data from an OLE DB data source.
包括从OLE DB数据源访问远程数据所需的所有连接信息。 This method is an alternative to accessing tables in a linked server and is a one-time, ad hoc method of connecting and accessing remote data by using OLE DB.
此方法是访问链接服务器中的表的替代方法,并且是使用OLE DB连接和访问远程数据的一次性临时方法。 For more frequent references to OLE DB data sources, use linked servers instead.
要更频繁地引用OLE DB数据源,请改用链接服务器。
How 怎么样
The upsides 优点
The downsides 缺点
Alternatives 备择方案
But as astander says, there is no real technical issue in accomplishing cross server sql. 但是正如旁观者所言,完成跨服务器sql并没有真正的技术问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.