SQL Server SYSADMIN account and DBO Role

Ed Hall 41 Reputation points
2020-09-18T21:18:26.87+00:00

Hello, My understanding is that when a SQL DB is created the SYSADMIN role is assigned the DBO role. My question is, if SYSADMIN has DBO formally removed and is assigned another role later, like db_datareader, does it still retain DBO level permissions in the database?

SQL Server | Other
0 comments No comments
{count} votes

Accepted answer
  1. m 4,276 Reputation points
    2020-09-21T02:43:44.107+00:00

    Hi @Ed Hall ,

    Hello, My understanding is that when a SQL DB is created the SYSADMIN role is assigned the DBO role. My question is, if SYSADMIN has DBO formally removed and is assigned another role later, like db_datareader, does it still retain DBO level permissions in the database?

    Yes. It does. Becasue it is one member of SYSADMIN role. One user who is SYSADMIN, in other words, if one who has SYSADMIN permission, he can perform any activities in this server.

    In your case, app-user and DBO all members of SYSADMIN, so ther is no use to change roles at database level.

    Note: It is generally not recommended to directly assign server roles to users, because server roles are global, which means that you have server-level permissions. It is generally recommended to assign databases to users and then assign database role permissions to the corresponding databases. Do not add the database role created by the user to the fixed server database role, otherwise it will cause the fixed database role to be upgraded.

    Next, let us clarify the server-level role and database-level role.
    25957-20200921serverrole.jpg
    25935-20200921databaserole.jpg

    More information:permissions-hierarchy-database-engine, sql-server-create-user

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2020-09-18T21:59:06.627+00:00

    Any user who is member of the sysadmin role maps to the dbo user in all databases.

    The opposite does not apply. If a non-privileged login owns a database, that login maps to dbo in that database, and has full powers in that database, but does not have sysadmin permission.

    A database user can also be member of the db_owner role, and then has permissions in the database on equal footing with dbo.

    I am not sure that I understand your question. If you are sysadmin, you are dbo in all databases - and that is never going to change.


  2. m 4,276 Reputation points
    2020-09-22T01:36:31.113+00:00

    Hi @Ed Hall ,

    Is the reply helpful?

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

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.