Mudar o ownership de um objecto

sp_changeobjectowner

Fonte: http://msdn2.microsoft.com/en-us/library/Aa259618(SQL.80).aspx

New Information – SQL Server 2000 SP3.

Changes the owner of an object in the current database.

Syntax

sp_changeobjectowner [ @objname = ] object‘ , [ @newowner = ] owner

Arguments

[@objname =] object

Is the name of an existing table, view, user-defined function, or stored procedure in the current database. object is nvarchar(517), with no default. object can be qualified with the existing-object owner, in the form existing_owner.object.

[@newowner =] owner

Examples

This example changes the owner of the authors table to Corporate\GeorgeW.

EXEC sp_changeobjectowner 'authors', 'CorporateGeorgeW' 

Is the name of the security account that will be the new owner of the object. owner is sysname, with no default. owner must be a valid Microsoft® SQL Server™ user or role, or Microsoft Windows NT® user or group in the current database. When specifying Windows NT users or groups, specify the name the Windows NT user or group is known by in the database (added using sp_grantdbaccess).

Return Code Values

0 (success) or 1 (failure)

EXEC sp_changeobjectowner ‘authors’, ‘Corporate\GeorgeW’

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *