A schema was created with the name of a windows user [DOMAIN\Foo]. I receive this error message when attempting to drop the schema.
DROP SCHEMA [DOMAIN\foo]
Msg 15151, Level 16, State 1, Line 8
Cannot drop the schema 'DOMAIN\foo', because it does not exist or you do not have permission.
The statement has been terminated.
I have already made sure that the user does not have authorization on the schema, and transferred ownership to dbo
alter authorization on schema::[DOMAIN\foo] to dbo
- My windows login is a member of the server role sysadmin.
- My user mapped to the database is a member of the database role db_owner.
Best Answer
The root of the problem is that I have a schema-only database defined that is generated automatically via triggers. When a DDL statement gets replayed by the INSERT trigger of the changelog table, the error occurs when the schema is out of sync (The schema did not exist in my
SchemaOnlyDatabase
). The error was being thrown in the context of the SchemaOnlyDatabase, not the database that was currently active TheDevDatabase, but that was not clearly indicated by the message.