Wednesday, July 26, 2017

SQL Server -- failure to change the database owner?

One of my customers sent me this error today -- 

     Msg 15110, Level 16, State 1, Line 14
     The proposed new database owner is already a user or aliased in the database.

Said he was trying to change the database owner for a new application.  I asked him to show me what he did, and he sent me this screenshot:



The correction here is fairly simple -- Drop the svcUSR from the database, and add it back in with the ALTER AUTHORIZATION statement.  Like this:

     USE utility;
     DROP USER svcUSR;

     -- add it back in AND change the dbowner
     ALTER AUTHORIZATION ON DATABASE::utility TO svcUSR;    


Very quick, very easy.  Take a look at this for more details regarding ALTER AUTHORIZATION: