Tag Archives: SQL 2012

How to find all the owners of your SQL databases

Sometimes when you go true your list of databases in SQL Studio Manager you notice the owner of the database is somebody who left the company for quite some time. This can happen because the database was create while that person was logged in at that time and he automatically became the owner.

A lot of times accounts are put to disabled in the Active Directory and a scheduled to be deleted an X period later. That’s the moment that problems can arise.

It’s better to make sure your databases are owned by a service account or something like SQLadmin or SA (SQL System Admin). The query below gives you a list of all your database names with the owners so you know which once to change.

 

The Query

select suser_sname(owner_sid),name
from sys.databases

 

Tip to modify your query

If you like to see more columns for what reason so ever. Type , * in the query and you get all the columns including the header names. Now you know what the column is called and you can use that name instead of the * star. Now your query is expanded with the extra column.

 

How to Change?

Right click your database go to properties and under Files in the left column you get the option to modify the database owner in the right part of the screen.