'How are you supposed to get the DacPac version from a SQL database script in Azure?

Azure SQL won't let you hit other databases when running in context of a script in the deployed database, so running SELECT type_version FROM master.dbo.sysdac_instances just results in the error:

Reference to database and/or server name in 'master.dbo.sysdac_instances' is not supported in this version of SQL Server.

I'm trying to use a manually run deployment script that leverages the version, but it needs to run in the connection to the deployed database, and Azure isn't letting it reach master. Is there an alternative way to get the DacPac version?



Solution 1:[1]

You cannot add the database name in the query unless you are in the same database. Your query will execute fine from the master database.

Alternatively, you need to create the cross-database connection and create an external table to query the data in master.

You can refer to this document for cross-database queries.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NiharikaMoola-MT