I have 2 fdb databases company.fdb
and timeAtt.fdb
company.fdb
contains staffDetail
table
staffId - 001
staffName - Andy
staffStatus - Active
timeAtt.fdb
contains staffAtt
table
staffId - 001
staffName - Andy
timeIn - 07:30
timeOut - 04:30
LI - X (late in)
AB - X (absent )
remarks - Emergency leave
Now, i would like to view the staff who was absent only which i did it this way
SELECT staffId,staffName,remarks FROM timeAtt.fdb WHERE AB = 'X'
But the problem is, the query also display inactive staff. So i need to join staffAtt
from timeAtt.fdb
and staffDetail
from company.fdb
to display only staff with active status. How can i do that?
SQL Server allows you to join tables from different databases as long as those databases are on the same server. The join syntax is the same; the only difference is that you must fully qualify table names.
Specifically, you can create a batch sync node, specify tables in multiple databases as the source tables, and then specify the destination table. After that, you can run the batch sync node to synchronize the data from the source tables to the destination table.
Starting with SQL Server 2014 (12. x), memory-optimized tables do not support cross-database transactions. You cannot access another database from the same transaction or the same query that also accesses a memory-optimized table.
As Mark notes you cannot join them directly. But you can still use a DSQL statement to get what you want.
Use execute block
and execute statement
together. Here's a sample.
execute block
returning (
staffId integer,
staffName varchar(100),
remarks varchar(100)
staffStatus varchar(10))
as
begin
for SELECT staffId, staffName, remarks
FROM timeAtt
WHERE AB = 'X'
into :staffId, :staffName, :remarks do begin
execute statement 'select staffStatus from company where staffId = ' || staffId
on external "your:connection:\string\and\db.fdb" as user FOO password BAR
into :staffStatus;
suspend;
end
end
You can't. In Firebird you can only join tables in the same database file. Firebird 2.5 expanded EXECUTE STATEMENT
to also execute a statement on an external datasource, but having a single query reference tables in different databases is not possible.
You have the following options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With