Click to Rate and Give Feedback
TechNet
TechNet Library
SQL Server
SQL Server 2008
Database Engine
Technical Reference
 sp_changedbowner (Transact-SQL)
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
Other versions are also available for the following:
SQL Server 2008 Books Online (October 2009)
sp_changedbowner (Transact-SQL)

New: 23 January 2009

Changes the owner of the current database.

ms178630.note(en-us,SQL.100).gifNote:
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER AUTHORIZATION instead.

Topic link icon Transact-SQL Syntax Conventions

sp_changedbowner [ @loginame = ] 'login'
          [ , [ @map = ] remap_alias_flag ]
[ @loginame = ] 'login'

Is the login ID of the new owner of the current database. login is sysname, with no default. login must be an already existing SQL Server login or Windows user. login cannot 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, drop the user within the current database first.

[ @map = ] remap_alias_flag

The remap_alias_flag parameter is deprecated because login aliases have been removed from SQL Server. Using the remap_alias_flag parameter does not cause an error but has no effect.

0 (success) or 1 (failure)

After sp_changedbowner is executed, the new owner is known as the dbo user inside the database. The dbo has implied permissions to perform all activities in the database.

The owner of the master, model, or tempdb system databases cannot be changed.

To display a list of the valid login values, execute the sp_helplogins stored procedure.

Executing sp_changedbowner with only the login parameter changes database ownership to login.

You can change the owner of any securable by using the ALTER AUTHORIZATION statement. For more information, see ALTER AUTHORIZATION (Transact-SQL).

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.

EXEC sp_changedbowner 'Albert'
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker