SetOwner Method (SQL-DMO)

The SetOwner method reassigns ownership for a Microsoft® SQL Server™ database.

Applies To

Database Object

Syntax

object.SetOwner( LoginName , [ TransferAliases ] , [ OverrideIfAlreadyUser ] )

Part Description
object Expression that evaluates to an object in the Applies To list.
LoginName String specifying an existing SQL Server login by name.
TransferAliases Optional. True or False as described in Settings.
OverrideIfAlreadyUser Optional. True or False as described in Settings.

Settings

The TransferAliases argument is maintained for compatibility with earlier versions of SQL Server security relying on aliases to assign privilege. For database ownership privilege based on membership in the db_owner role, the argument can be ignored safely. Set TransferAliases by using:

Set OverrideIfAlreadyUser by using:

Remarks

Reassigning ownership of a SQL Server database by using the SetOwner method requires appropriate privilege. The SQL Server login used for SQLServer object connection must be the current database owner or a member of the fixed role sysadmin.

Prototype (C/C++)

HRESULT SetOwner(
SQLDMO_LPCSTR NewValue,
BOOL bTransferAliases = FALSE,
BOOL bOverrideIfAlreadyUser = FALSE);

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.