Reputation: 558
I have a series of Azure SQL Data Warehouse databases on differing logical servers. I primarily use DBeaver to interact with them (as we are working to get the ADW-capable version of Management Studio deployed).
I have JDBC connections configured from DBeaver for all the various databases but uniquely on one database's connection, when attempting in DBeaver to navigate the object tree, the following error occurs when expanding the tables, views, indexes, and procedures to show the list of said objects:
SQL Error [104455] [S0001]: USE statement is not supported to switch between
databases. Use a new connection to connect to a different
Database.com.microsoft.sqlserver.jdbc.SQLServerException: USE statement is
not supported to switch between databases. Use a new connection to
connect to a different Database.
The various ADW databases and servers were provisioned within weeks of each other by our local Azure enablement team (including MSFT staff). I personally created the logins/users on the databases using the same T-sql.
Why would the behavior be different on these PaaS databases?
Upvotes: 2
Views: 5106
Reputation: 2053
The SQL server in Azure is a logical container, not the same physical container as the server (aka instance) in the box version of SQL Server. That introduces a number of differences including the inability to support "USE" as it is currently implemented. More details on this is documented on https://learn.microsoft.com/en-us/azure/sql-database/sql-database-transact-sql-information
When you connect to Azure SQL DB or SQL DW, SSMS first connects to master to get the list of databases (and some other stuff). When you navigate the Object Browser in SSMS to look at various objects in different DBs/DWs/StretchDBs, it will open a new connection for each database you browse.
From your description, it looks like the version of DBeaver you used is operating under the assumption it is connected to the local SQL Server hence the "USE" failure. Suggest you ping them to see if they plan to address this in some future update. You can also add your vote and comments to the Azure SQL DB feedback page https://feedback.azure.com/forums/217321-sql-database/suggestions/14822082-allow-the-use-statement-to-switch-between-database
Upvotes: 3