Introduction

Due to a default behavior of SQL Server, database ownership is assigned to the account that created the database. Some applications are using database ownership as an access to the database as opposed to using explicit database roles.

Problem

Change database ownership for Windows/AD-based accounts to SA. The benefit is that ownership by SA has less dependency on Active Directory and individual user accounts.

Solution

https://github.com/steverezhener/DBA/blob/master/Procedures/bestpractices.usp_change_database_ownership.sql

Example