0

I try to connect to one of my Azure Database jdbc:sqlserver://***.database.windows.net:1433;database=Product, I can query from Product.

Then I try to connect my Azure database jdbc:sqlserver://***.database.windows.net:1433 and fail to query from any database any table with error "Reference to database and/or server name is not supported in this version of SQL Server"

Is this related to cross database query mentioned in Cross-Database Queries in Azure SQL Database ? If not, is there any method to do a connection to query from any database?

KC L
  • 79
  • 1
  • 6
  • Does this answer your question? [Can't query between databases in SQL Azure](https://stackoverflow.com/questions/11284998/cant-query-between-databases-in-sql-azure) – tgdavies Jan 20 '22 at 05:26
  • @tgdavies I have read this before. So if my function may query many difference database, then I need to create EXTERNAL DATA SOURCE for all the database I may reached? – KC L Jan 20 '22 at 06:19

1 Answers1

0

As per the Microsoft official documentation, this is the standard and recommended way in configure file to connect with Azure SQL Database.

You can use environment variable to change the database name.

Set database=YOUR_DB_NAME and use the variable name in the URL:

jdbc:sqlserver://***.database.windows.net:1433;${database}

Utkarsh Pal
  • 4,079
  • 1
  • 5
  • 14