开发者

Ask query from Delphi with UniDAC components in two SQL Server databases on same server

开发者 https://www.devze.com 2023-02-24 04:41 出处:网络
I want to run a query w开发者_如何学运维ith TUniQuery (UniDAC components) in two SQL Server databases located on the same server. I think two TUniConnections must be linked on the same query component

I want to run a query w开发者_如何学运维ith TUniQuery (UniDAC components) in two SQL Server databases located on the same server. I think two TUniConnections must be linked on the same query component. Is there any other way to get simultaneously data from both databases? Thanks.


Just use the full table name: <database>.<schema>.<table>. In the same query you can reference tables from different databases. So, no need for second connection !


AFAIK, you can't use two TUniConnections on the same query component at the same time.

The proper way to do this is to set up one SQL Server database to know about the other one by making it a linked server. This allows a single SQL SELECT statement to refer to both tables in the current database and tables in a different one, allowing JOINs or UNIONs. It also allows replication, distributed loads, and other benefits if you need them.

0

精彩评论

暂无评论...
验证码 换一张
取 消