SetOwner Method

SQLServer.Database Object

Description

Changes the owner of a database (DBO) to a new login.

Visual Basic

Database.SetOwner (
[LoginName :=] idLogin,
[[TransferAliases :=] bTransfer,]
[[OverrideIfAlreadyUser :=] bOverride] )

C++

HRESULT pDatabase->SetOwner (
SQLOLE_LPCSTR
idLogin,
BOOL
bTransfer = FALSE,
BOOL
bOverride = FALSE );

Elements

Element Type Description

idLogin Identifier Login of the new database owner
bTransfer Boolean Determines if existing aliases and permissions are transferred to the new database owner. The default is False.
bOverride Boolean Determines if the database ownership should still be changed if the new login is already a user in this database. If True, the specified login will become the new database owner. If False, the specified login will become the new database owner only if that login is not a user in this database. The default is False.

Remarks

This is an indexed property.

Reference

sp_changedbowner