Monday, March 26, 2012

No dbo for a database - but there are db_owner users

I have a number of user databases who have lost their owner. That is, displaying properties for the database says the owner is unknown.

I assume that any user for such a database that's assigned to the db_owner role can admin everything in this database? Which means that the lack of a dbo doesn't cause any other problem than making it impossible to run a sp_helpdb for the database, or...?

Of course I'd like to make someone the owner, but it seems difficult to make an already existing database user the owner, without dropping the user and re-creating it.Methinks you need sp_changedbowner (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_ca-cz_30s2.asp), which makes the fix trivial anywhere you can execute a stored procedure (such as in Query Analyzer).

-PatP|||Yes, but it doesn't work if the user to be the new owner is already a user in that database. Seems like I need to drop the user and re-create it?|||Yep. Otherwise, SQL Server would have to make a choice about what permissions to grant that user. Especially if that user were dropped from db_owners. The user should see no difference, unless they have created objects under their own username.

No comments:

Post a Comment