How do I change the default database owner for new databases in SQL Server?
2
votes
1
answer
4623
views
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 'OLDNAME\user', error code 0x534. (Microsoft SQL Server, Error: 15404).
I used the following instructions to rename the server:
sp_dropserver 'OLDNAME\SQLEXPRESS';
GO
sp_addserver 'NEWNAME\SQLEXPRESS','local';
GO
-- Restart Server
SELECT @@SERVERNAME; -- NEWNAME\SQLEXPRESS
However, this did not affect the default owner for new databases. They are still being created with the owner as OLDNAME\user
, 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?
Asked by Manngo
(3145 rep)
Mar 10, 2022, 08:37 PM
Last activity: Mar 11, 2022, 11:58 AM
Last activity: Mar 11, 2022, 11:58 AM