While moving databases around within SQL to optimize IOPS and/or drive utilization, you might have a need to put the Database Owner back to what it was originally. Before you drop your databases, take a look at the DBO first.
This will grab all the dbo's of all the databases on your server:
select SUSER_SNAME(owner_sid) as username, name from sys.databasesNow, if you want to change the DBO...
sp_changeDbOwner @loginame = 'domain\username'However, you might run into an error is the DBO is already a user or aliased in the database.
USE <databaseName> GO SP_DROPUSER 'domain\username' GO SP_CHANGEDBOWNER 'domain\username'UPDATE 02/04/2015
Added drop user and change owner code.
No comments:
Post a Comment