Blog Post

ALTER AUTHORIZATION sql to change owner of a database

,

ALTER AUTHORIZATION changes the ownership of  entities .  Server level entity ownership can be changed to server- level principals. Database level ownership can be changed to database level principals.

ALTER AUTHORIZATION can change database ownership.  This replaces sp_changedbowner.  Alter any security management scripts using sp_changedbowner  - such as Attach database without log file and rename database

According to SQL Server BOL

“This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER AUTHORIZATION instead”

An example of ALTER AUTHORIZATION : a database  without an owner , may require an owner to be assigned. The login used to create the database or be assigned the database ownership  has been dropped. The database does not have an owner.

Using ALTER AUTHORIZATION assigns an owner.

 Example:

 ALTER AUTHORIZATION ON DATABASE::MyDatabase TO MyLoginUser;

 

There are special conditions around the usage of ALTER AUTHORIZATION . Read SQL Server BOL for details.

 

Author: Jack Vamvas (http://www.sqlserver-dba.com)


Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating