sp_changedbowner

Description

Changes the owner of a user database.

Syntax

sp_changedbowner loginame[, true]

Parameters

loginame

is the login name of the new owner of the current database.

true

transfers aliases and their permissions to the new database owner. Values are “true” and “TRUE”.

Examples

Example 1

Makes the user “albert” the owner of the current database:

sp_changedbowner albert

Usage

Permissions

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

Granular permissions enabled

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

Granular permissions 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:

Event

Audit option

Command or access audited

Information in extrainfo

38

exec_procedure

Execution of a procedure

  • 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

See also

Commands create database

System procedures sp_addlogin, sp_dropalias, sp_dropuser, sp_helpdb