Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
Salvor71
Regular Visitor

Fabric SQL Databases cross reference

I've created two SQL datadases, DB1 and DB2, and I'd like to cross-reference objects (i.e. views, functions...) in my queries but it doesn't work, even when I use the "extended" name needed to connect to the db's with SMSS. If I run in database DB2 the query "select * from [DB1-afb3707b-10e5-4eaf-a96f-ff5d3d465b9a].logging.LogLevel" I get the error "Reference to database and/or server name in 'DB1-afb3707b-10e5-4eaf-a96f-ff5d3d465b9a.logging.LogLevel' is not supported in this version of SQL Server".

Is it possible, or will it be?

P.S. I don't mean cross-querying through the SQL endpoint, but db to db like you can do with Sql Server.

1 ACCEPTED SOLUTION
Salvor71
Regular Visitor

Hi @nilendraFabric ,

yes I tried and it doesn't work, but now I'm clearing my head on this.

For what I see, when you use the logical database name you are always referring to the SQL endpoint. Also, the only objects of the SQL database visible through the SQL endpoint are the tables: my logging.LogLevel view is defined in the database and I don't see it in the Views folder of the SQL endpoint, but I can create the same view in the Sql endpoint so that in a way solves the problem.

Anyway you cannot reference the SQL endpoint from its database counterpart: if I run the query

SELECT * FROM DB1.logging.LogLevel; 

in the database DB1 I get the same reference error. If I run it from the SQL endpoint of another database, it works.

So, in conclusion, cross-database reference is (currently?) only for SQL endpoint as stated in the docs, that's why I asked whether it will be supported in the future. We'll see.

View solution in original post

7 REPLIES 7
v-sgandrathi
Community Support
Community Support

Hi @Salvor71,

 

I'm glad to hear your query has been clarified! To make it easier for others in the community to find this solution, please consider marking your response as the accepted solution and giving Kudos to the reply that helped you. Thank you for sharing your experience!
We truly appreciate your participation in the Microsoft Community Forum!

Thankyou

Salvor71
Regular Visitor

Hi @nilendraFabric ,

yes I tried and it doesn't work, but now I'm clearing my head on this.

For what I see, when you use the logical database name you are always referring to the SQL endpoint. Also, the only objects of the SQL database visible through the SQL endpoint are the tables: my logging.LogLevel view is defined in the database and I don't see it in the Views folder of the SQL endpoint, but I can create the same view in the Sql endpoint so that in a way solves the problem.

Anyway you cannot reference the SQL endpoint from its database counterpart: if I run the query

SELECT * FROM DB1.logging.LogLevel; 

in the database DB1 I get the same reference error. If I run it from the SQL endpoint of another database, it works.

So, in conclusion, cross-database reference is (currently?) only for SQL endpoint as stated in the docs, that's why I asked whether it will be supported in the future. We'll see.

v-sgandrathi
Community Support
Community Support

Hi @Salvor71,

Thanks for using Microsoft Fabric Community Forum.


Thankyou @nilendraFabric  and @NandanHegde  I appreciate your prompt response to the issue. The solution provided by the community members may resolve your issue.

Additionally, here are some key points that might help you:

Please verify the SQL Server version and the compatibility level, as these settings can impact the behavior of cross-database queries.
The error message indicates that your current SQL Server version may not support cross-database queries as intended. If your version has limitations on cross-database access, consider upgrading to a newer version that supports this feature.
When executing queries that reference objects across multiple databases (e.g., tables, views, functions), ensure the user running the query has the necessary permissions in both databases.

Here is the Microsoft documentation Link on cross database queries you can refer for your idea:
SQL database Overview (Preview) - Microsoft Fabric | Microsoft Learn

 

If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

Regards,
Sahasra.

Hi @v-sgandrathi,

unfortunately the SQL server version is not something you can manage in Fabric, but I understand that things are evolving quite rapidly. I was trying to replicate the architecture I use in many of my projects where I have a service database that offers common services to the other databases on the same instance, like logging, configuration, validation etc. I think I can still do it but in the Fabric way.

NandanHegde
Super User
Super User

Based on my understanding, cross database query is not supported in fabric SQL database as at the backend it is using Azure SQL database engine.

 

Note: the SQL analytics endpoint does support it




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Hi @NandanHegde,

yes, but with some limitations.

Anyway I think Fabric SQL database is just what was missing in the Fabric environment.

nilendraFabric
Community Champion
Community Champion

Hello @Salvor71 

 

have you tried using the logical database name without GUIDs or workspace identifiers:

SELECT * FROM DB1.logging.LogLevel; 

Helpful resources

Announcements
FBCApril_Carousel

Fabric Monthly Update - April 2025

Check out the April 2025 Fabric update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.