- Writing Cross-Database Queries: You can write queries that access data from different databases within the same Microsoft Fabric workspace.
- Examples and Methods: There are different ways to do this, and we’ll explore some examples. You can join tables or views from different databases to perform queries within the same workspace.
- Adding SQL Analytics Endpoint or Warehouse: You can add a SQL analytics endpoint or warehouse from your active workspace to the object explorer. This makes it easy to reference them when writing SQL queries or creating visual queries. You can refer to tables in added databases using a three-part name.

- Example: For instance, if you add a database named ContosoLakehouse, you can reference a table called ContosoSalesTable from that database using its three-part name in your query.
SELECT *
FROM ContosoLakehouse.dbo.ContosoSalesTable AS Contoso
INNER JOIN Affiliation
ON Affiliation.AffiliationId = Contoso.RecordTypeID;
Using three-part naming to reference the databases/tables, you can join multiple databases.
SELECT *
FROM ContosoLakehouse.dbo.ContosoSalesTable AS Contoso
INNER JOIN My_lakehouse.dbo.Affiliation
ON My_lakehouse.dbo.Affiliation.AffiliationId = Contoso.RecordTypeID;
Using three-part naming to reference the database and tables, you can insert data from one database to another.
INSERT INTO ContosoWarehouse.dbo.Affiliation
SELECT *
FROM My_Lakehouse.dbo.Affiliation;
You can drag and drop tables from added databases to Visual query editor to create a cross-database query.
