Compartir a través de


SetOwner Method

Esta característica se quitará en una versión futura de Microsoft SQL Server. Evite utilizar esta característica en nuevos trabajos de desarrollo y tenga previsto modificar las aplicaciones que actualmente la utilizan.

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

Sintaxis

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

Parts

  • object
    Expression that evaluates to an object in the Applies To list.
  • LoginName
    String that specifies 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.

Prototype (C/C++)

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

Settings

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

  • TRUE. Logins aliased to the login of the current database owner are realiased to reference the new owner.
  • FALSE (default). No change is made in alias logins.

Set OverrideIfAlreadyUser using:

  • TRUE. A user existing in the database and mapped to the login that will assume ownership is dropped prior to the change in ownership.
  • FALSE (default). No change in user definition is made. If the login that will assume ownership is mapped to an existing user, the method fails.

Notas

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

Applies To:

Database Object