Dev/Test Environment For Databases With Cross-Database Joins We have existing databases under source control in SQL Server Database Projects with a number of these databases referencing each other.

Getting these into projects and source control was challenging enough though I'm finding it difficult to setup Dev/Test environments without using a new SQL server instance.

At the moment we have a copy of the databases on a test SQL instance which is being used as part of continuous deployment. What I am looking to do is to develop in a branch and work against databases with a Dev prefix on the same instance, though realise that these would be referencing the databases used for continuous deployment.

Would this be possible by using Databases variables in Database References rather than just the name, if so how and is there a way to share SQLCMD variables across projects? Are there any alternative ways to consider?
I would tend to suggest using multiple publish.xml files as described here Jamie Thompson blog

The database names (or a prefix) could then be stored as SQLCMD variables.

Each publish file would then be built and published as a build artifact - you'd need to code a custom powershell or batch job to pick the correct file based on the server name. (You could use the server name as a switch here)

You would need to set up the publish file for each environment once, but once that job is done, it won't need doing again.