1

I want to run a query with 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.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
GBAKAS
  • 61
  • 1
  • 2
  • 4

2 Answers2

0

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 !

robmil
  • 312
  • 2
  • 4
0

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.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • You do not need to do that when the databases are on the same SQL server instance. Which I think is the case for the OP. At least when "on the same server" doesn't just mean the same machine, but actually the same SQL server instance. – Marjan Venema Apr 13 '11 at 17:19
  • I think you're probably right, now that I re-read the question. Until we hear back from the OP, I'll leave my answer in case it's helpful. If it's totally off-base, I'll delete it to get it out of the way. :) – Ken White Apr 13 '11 at 19:42