Skip to main content
< All Topics
Print

Wrong database owner

When creating a database, the default owner of the database will be the person creating it. If that person leaves the company and the AD account is disabled, working with the database can cause problems. It is advised to set the database owner to the sa account.

To query the Performance Store database for wrong database owners, use:

select d.*
from dbo.v_databases d
inner join dbo.v_servers s on s.server_name = d.server_name
left join dbo.database_owner_whitelist w on w.server_name = d.server_name and w.database_name = d.database_name 
and w.owner_name = d.owner_name
where d.owner_sid != 0x01
and d.state_desc = 'ONLINE'
and w.server_name is null
order by d.server_name, d.database_name

The alert will be visible on the Latest stats dashboard.

To exclude specific servers from this alert, see how to use the dbo.team_alert_exclude table in Alerting.

Table of Contents