Why do I (they) own that database?

, 2019-02-20

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.

Rate

Share

Share

Rate

Related content

Database Mirroring FAQ: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup?

Question: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? This question was sent to me via email. My reply follows. Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? Databases to be mirrored are currently running on 2005 SQL instances but will be upgraded to 2008 SQL in the near future.

2009-02-23

1,567 reads

Networking - Part 4

You may want to read Part 1 , Part 2 , and Part 3 before continuing. This time around I'd like to talk about social networking. We'll start with social networking. Facebook, MySpace, and Twitter are all good examples of using technology to let...

2009-02-17

1,530 reads

Speaking at Community Events - More Thoughts

Last week I posted Speaking at Community Events - Time to Raise the Bar?, a first cut at talking about to what degree we should require experience for speakers at events like SQLSaturday as well as when it might be appropriate to add additional focus/limitations on the presentations that are accepted. I've got a few more thoughts on the topic this week, and I look forward to your comments.

2009-02-13

360 reads