sp_changedbowner

Changes the owner of a user database.

Syntax

sp_changedbowner loginame[, true]

Parameters

Examples

Usage

There are additional considerations when using sp_changedbowner:
  • The new owner must not already be known as either a user or alias (that is, the new owner must not already be listed in sysusers or sysalternates). Executing sp_changedbowner with the single parameter loginame changes the database ownership to loginame and drops aliases of users who could act as the old “dbo.”

  • After executing sp_changedbowner, the new owner is known as the database owner inside the database.

  • sp_changedbowner cannot transfer ownership of the system databases.

  • The new owner must already have a login name in the SAP ASE server, but must not have a database user name or alias name in the database. To assign database ownership to such a user, drop the user name or alias entry before executing sp_changedbowner.

  • To grant permissions to the new owner, a system administrator must grant them to the database owner, since the user is no longer known inside the database under any other name.

See also create database in Reference Manual: Commands.

Permissions

The permission checks for sp_changedbowner differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with own any database privilege.

Disabled

With granular permissions disabled, you must be a user with sa_role.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_addlogin
sp_dropalias
sp_dropuser
sp_helpdb