Manage Database Owners

From the archives … To list database owners

SELECT name, SUSER_SNAME(owner_sid) owner 
FROM sys.databases;

To change a database owner to ‘sa’

USE SomeDatabaseName;

EXEC sp_changedbowner sa;

To change ALL database owners to ‘sa’

EXEC sp_msforeachdb 
'USE [?]; IF db_id() > 4 EXEC sp_changedbowner sa';

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s