Domain user that not exist as DB owner

Alen Cappelletti 992 Reputation points
2020-10-22T08:17:39.55+00:00

Hi, I would like to know if could be some problem leaving a DOMAIN\USER that not exist more like DB owner.
I saw that exist cases in some DB in different instances.
Alen, Italy

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,286 questions
{count} votes

Accepted answer
  1. Ben Miller (DBAduck) 956 Reputation points
    2020-10-22T14:03:03.6+00:00

    There are some functions in SQL like CLR Assembly loading that will fail to work if the owner is not there. Anything in the database on startup dealing with Security will fail if the DB Owner user is no longer valid or missing.


2 additional answers

Sort by: Most helpful
  1. m 4,271 Reputation points
    2020-10-22T09:50:32.227+00:00

    Hi @Alen Cappelletti ,

    I would like to know if could be some problem leaving a DOMAIN\USER that not exist more like DB owner.

    That is because the domain\user not be added into db_owner role.

    Domain user and DB owner, they are different concept level.

    Domain user:Damain user is the Active Directory account created under your company domain;
    Db_owner:one fixed database role can perform all configuration and maintenance activities on the database;

    If my understanding is correct, you want to add one domain user as db_owner, try steps as next(please change database name and domain\account to yours on your side):

     use test1021  
     Go  
      
    --STEP1:Creating a login from a Windows domain account(if you have already created,skip this step)  
    CREATE LOGIN [YX\TEST2] FROM WINDOWS;  
      
    --STEP2:Add that user as a login to the database(if you have already created,skip this step)  
    CREATE USER [YX\TEST2] FOR LOGIN [YX\TEST2]  
      
    --STEP3:Add that user to the db_owner  
    EXEC sp_addrolemember N'db_owner', N'YX\TEST2'  
    

    34331-20201022dbowner2.jpg

    BR,
    Mia


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


  2. Shashank Singh 6,251 Reputation points
    2020-10-22T12:52:52.287+00:00

    My question is if the eventuality I could miss some updates o fixes, in a case of detach/attach or some other DBA activity the link with this "old" user could be dangerous for some administrative activities on DS's?

    No, this would not be dangerous. You would be able to perform task on database even if its owner no longer exists. I dont have thorough list as what could go wrong but I had seen such situation and frankly the database just worked fine. Like @Dan Guzman mentioned change it to valid account or SA ( for time being) .

    0 comments No comments