7:46 PM
That's what I thought. There's no equivalent issue.
The issue is that I want my application database to look exactly like a customer install (i.e. it is using my existing installer process deployed to the various environments and configurations - SQL2012, SQL2016, etc) and then I want to run all my tests. So I had tSQLt and TEST schema and everything, but I don't want them in there making the database different. So all my test code and tables of tests runs from the DataMartTest DB alongside it, querying across.
Stuff that works inside the database, doesn't work when forklifted and it isn't just a matter of prefixing. And that's what's annoying.
SELECT SCHEMA_NAME(schema_id), etc FROM sys.service_queues can't just become SELECT DataMart.SCHEMA_NAME(schema_id) FROM DataMart.sys.service_queues you have to join to a DataMart.sys.schemas instead - and of course, now you have to alias the tables too because there are overlapping column names like schema_id and name. There are a bunch of functions like that which would be good if there was a server-wide equivalent (even if you had to pass the databasename to it as a parameter)