Nugget: Get and set SQL Server DB owner

In this nugget I will share my findings on how get and set the owner of a database in SQL Server.

To get the owners of all databases on the current SQL Server instance:

SELECT name, SUSER_SNAME(owner_sid) from sys.databases;

To set the owner of a database:

ALTER AUTHORIZATION ON DATABASE::{database_name} TO {user};
References:

invalidlogic.com sqlservercentral.com