Changes the owner of a database.
sp_changedbowner login_id [, true]
where
The sp_changedbowner system stored procedure makes login_id the owner of the current database.
The new database owner must already have a login ID on SQL Server but must not have a database name or alias name in the current database. To assign database ownership to such a user, drop the user's database name and alias entries before executing sp_changedbowner.
After the sp_changedbowner system stored procedure is executed, the new owner is known as the database owner inside the database.
To grant permissions to a user who is the new owner, the system administrator must grant the permissions to the database owner, because the user is known inside the database only by that other name.
This example makes the user Albert the owner of the current database.
sp_changedbowner Albert
Only the system administrator can execute this procedure.
master.dbo.sysdatabases, master.dbo.syslogins, sysalternates, sysusers
CREATE DATABASE | sp_dropuser |
sp_addlogin | sp_helpdb |
sp_dropalias |