I had always figured the .dbo.
you have to add to the schema name in SQL Server was just an annoyance introduced by Microsoft just because they can, but as pointed out here, the dbo part is actually the schema name, and what I thought of as the schema name is in fact the database name. (To my defense, every DBMS has a different interpretation of what database, schema, user, and table means). As a consequence, people using a different schema name than dbo are out of luck when using any of our applications.
A solution I would like to suggest is to make dbo part of the schema name parameter. So where we previously had
SELECT * FROM @cdm_schema.dbo.person;
with parameter value cdm_schema = 'myCdmSchema'
we will now have
SELECT * FROM @cdm_schema.person;
with parameter value cdm_schema = 'myCdmSchema.dbo'
To transition to this solution, I suggest we follow these steps:
- Modify SqlRender’s
translateSql()
function so it generates a warning when your parameterized SQL still contains.dbo.
- Modify all parameterized SQL in our applications to no longer use
.dbo.
(including ACHILLES, HERCULES, the methods library, and everything else) - After a grace period, remove the translation rule and warnings from SqlRender, meaning that everyone that hasn’t done step 2 will see their code break on any platform other than SQL Server
Any thoughts?