Ever looked at the list of databases and wonder why you own one of them? Or why some other user owns the database? Just to be clear, by owner I mean the one and only actual owner of the database, not just a member of the db_owner role. This can be a bit confusing when you know that you have a policy where the owner of the database is always supposed to be sa (which is also disabled by policy).
No, you didn’t make yourself the owner of the database while you were sleep-working, your co-worker didn’t suddenly go insane and decide they needed to own all of the databases. I’m pretty sure there are other ways this can happen, but every single time I’ve dealt with it, it was a create or a restore.
The owner of a database, until changed, is the person who either created it or the last person to restore it.
So if you or your co-worker did an operational restore and when you (or they) were done, the database now has a new owner. And chances are you (I’m not saying “or they” anymore in this post it’s getting annoying) didn’t think to check who was supposed to own it and change it back when you were done.
Fixing this is simple enough
-- Current command ALTER AUTHORIZATION ON DATABASE::Test TO sa; -- Older command (still works but may go away in the near future) USE Test; EXEC sp_changedbowner 'sa';
I should probably note that the DATABASE:: is required in this case. The class_type isn’t always required on these types of commands, but frequently with the higher level objects (databases for example), it is.