Cannot alter owned schema from any user

greenfield70 106 Reputation points
2020-10-30T09:42:04.543+00:00

Hello.

My details here below. (I use SQL Server 2019 Express on Windows 10)

SQL Server Management Studio 15.0.18338.0
SQL Server Management Objects (SMO) 16.100.41011.9
Microsoft Analysis Services Client Tools 15.0.19205.0
Microsoft Data Access Components (MDAC) 10.0.17763.1
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.17763

I am logged with sysadmin (both SA and Windows Admin, same result)
and a am trying to remove the owned schema to Dbo and another internal user that i created that has access to a db in my server

Accidentally i granted 2 schemas to dbo and to the other users, like this , e.g. (see screenshot)36178-schema.jpg

Then i applied the following query to remove it, elg. for ddladmin permissions

alter authorization
on schema::db_ddladmin
to dbo;

Unfortunately, even after loggin in and out and refreshed many times, the authorization are not dropped.

Is there any particular reason to it?

Thanks in advance.

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,624 questions
{count} votes

Accepted answer
  1. Guoxiong 8,206 Reputation points
    2020-10-30T14:55:13.11+00:00

    Right click on the schema db_ddladmin to select Properties. On the popup window, change dbo to db_ddladmin from Schema onwer and then click OK. Do the same on the schema db_denydatareader.

    2 people found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. 21986829 481 Reputation points
    2020-10-30T13:15:27.967+00:00

    The error message should tell you why you can't remove it.
    It is usually because the schema has objects related to itself.
    You would have to change those object's owner before removing

    1 person found this answer helpful.

  2. Erland Sommarskog 110.2K Reputation points
    2020-10-30T23:06:24.787+00:00

    ...or simply run SELECT * FROM sys.schemas. The column principal_id should be 1 for all schemas that are owned by dbo.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.