How do I change the default database owner for new databases in SQL Server?

The question:

I had cause to change my computer name (it’s running in a virtual machine). I have an existing SQLExpress instance which was installed prior to the rename.

There are some features which fail because new databases are still created with the old owner. More specifically, when I try to create a new database diagram, I get the below error.

Could not obtain information about Windows NT group/user ‘OLDNAMEuser’, error code 0x534. (Microsoft SQL Server, Error: 15404).

I used the following instructions to rename the server:

sp_dropserver 'OLDNAMESQLEXPRESS';
sp_addserver 'NEWNAMESQLEXPRESS','local';
--  Restart Server

However, this did not affect the default owner for new databases. They are still being created with the owner as OLDNAMEuser, who no longer exists.

I know how to change the owner of an existing database, after creation. But, how can I get new databases to have the correct owner to begin with?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

The default owner is going to be whoever creates the database. In your case, it sounds like you’re using a local computer account as a windows login for SQL Server. So, the login name is in the form of OLDNAMEuser; however, you would like new databases to be created with NEWNAMEuser as the owner.

Changes to Windows accounts are not propagated to SQL Server, so the old login name will persist until you manually change it. However, the login continues work because the SID is how SQL Server makes reference to it when authenticating the account.

To fix this issue you’ll need to use the ALTER LOGIN command to change the login name from OLDNAMEuser to NEWNAMEuser.


If you need to change the owner of an existing database, you can use ALTER AUTHORIZATION. I would recommend changing the database owner to someone other than a real user, such as [sa].

    TO <domain><user>

Another option would be to use EXECUTE AS LOGIN = 'owner_to_be', just ahead of the statement to be executed to create the database.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment