| title | sp_changedbowner (Transact-SQL) | ||
|---|---|---|---|
| description | sp_changedbowner changes the owner of the current database. | ||
| author | VanMSFT | ||
| ms.author | vanto | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE SQL Server]
Changes the owner of the current database.
Important
[!INCLUDE ssNoteDepFutureAvoid] Use ALTER AUTHORIZATION instead.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_changedbowner
[ @loginame = ] N'loginame'
[ , [ @map = ] 'map' ]
[ ; ]
The login ID of the new owner of the current database. @loginame is sysname, with no default. @loginame must be an already existing [!INCLUDE ssNoVersion] login or Windows user. @loginame can't become the owner of the current database if it already has access to the database through an existing user security account within the database. To avoid this scenario, drop the user within the current database first.
[!INCLUDE deprecated-parameter]
0 (success) or 1 (failure).
After sp_changedbowner is executed, the new owner is known as the dbo user inside the database. The dbo user has implied permissions to perform all activities in the database.
The owner of the master, model, or tempdb system databases can't be changed.
To display a list of the valid @loginame values, execute the sp_helplogins stored procedure.
Executing sp_changedbowner with only the @loginame parameter changes database ownership to @loginame.
You can change the owner of any securable by using the ALTER AUTHORIZATION statement. For more information, see ALTER AUTHORIZATION.
Requires TAKE OWNERSHIP permission on the database. If the new owner has a corresponding user in the database, requires IMPERSONATE permission on the login, otherwise requires CONTROL SERVER permission on the server.
The following example makes the login Albert the owner of the current database.
EXECUTE sp_changedbowner 'Albert';