How can I set myself as owner of a database ? just using sql

Posted on

Question :

As I want to view dependencies of just a couple of tables in my clients database I want to set myself as the owner of the database.

If the database is called MyDatabase and my userName is MyDomainMyUserName
How do I use the ALTER AUTHORIZATION statement to set myself as Owner ?

Answer :

Check this links and references:
http://technet.microsoft.com/en-us/library/ms178630.aspx

Example:

EXEC sp_changedbowner 'Albert'

and ALTER AUTHORIZATION

ALTER AUTHORIZATION ON OBJECT::Parts.Sprockets TO MichikoOsada;
GO

http://technet.microsoft.com/en-us/library/ms187359(v=sql.105).aspx

ALTER AUTHORIZATION ON DATABASE::MyDatabase TO MyUserName;

Leave a Reply

Your email address will not be published. Required fields are marked *