AzureSQL: Error executing a cross database query on the server with private endpoint

Sachin S 26 Reputation points
2025-06-20T23:27:34.55+00:00

Hello,

I'm trying to execute a cross database query on Azure SQLServer with multiple databases and run into error below: Any clue on how to go above resolving this?

Msg 46832, Level 16, State 3, Line 93

An error occurred while establishing connection to remote data source: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Reason: 

An instance-specific error occurred while establishing a connection to SQL Server. 

Connection was denied since Deny Public Network Access is set to Yes 

(https://docs.microsoft.com/azure/azure-sql/database/connectivity-settings#deny-public-network-access). 

To connect to this server, use the Private Endpoint from inside your virtual network 

(https://docs.microsoft.com/azure/sql-database/sql-database-private-endpoint-overview#how-to-set-up-private-link-for-azure-sql-database).

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Reason: An instance-specific error occurred while establishing a connection to SQL Server. 

Connection was denied since Deny Public Network Access is set to Yes 

(https://docs.microsoft.com/azure/azure-sql/database/connectivity-settings#deny-public-network-access). 

To connect to this server, use the Private Endpoint from inside your virtual network 

(https://docs.microsoft.com/azure/sql-database/sql-database-private-endpoint-ov

Have validate the below:

The Azure SQL Server has private endpoint with public access disabled

Can connect to source database on the Azure SQL database using SQL login (needed for external table creation in target database) and read the data

Can connect to the Azure SQL Server using AAD logins as well.

--on the target database have executed below

CREATE MASTER KEY ENCRYPTION BY  Password = 'Password'

CREATE DATABASE SCOPED CREDENTIAL Reader WITH IDENTITY = 'Reader' , SECRET = 'Secret';  

CREATE EXTERNAL DATA SOURCE [extdatasource] WITH (

    TYPE=RDBMS,

    LOCATION='server.database.windows.net', -- Replace with target server name

    DATABASE_NAME='database-name', -- Replace with target database name

    CREDENTIAL= Reader

CREATE EXTERNAL TABLE [tbl].Table1 ( Name varchar(100))

WITH (

DATASOURCE=extdatasource,

SCHEMA='tbl'

OBJECT_NAME = 'Table1'

)

--Error listed above occurs when running the query below

select * from tbl.Table1

Azure SQL Database
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.