SQL Database Principal

List all database owners which are not 'sa'

SELECT D.NAME AS 'Database'
	,S.NAME AS 'Owner'
FROM sys.databases D
LEFT JOIN sys.server_principals S ON D.owner_sid = S.sid
WHERE S.NAME <> 'sa'
	AND S.NAME IS NOT NULL

Generate scritps to alter database owner

SELECT 'ALTER AUTHORIZATION ON DATABASE::' + D.name + ' TO sa;'
FROM sys.databases D
LEFT JOIN sys.server_principals S ON D.owner_sid = S.sid
WHERE S.NAME <> 'sa'
	AND S.NAME IS NOT NULL

Troubleshooting SQL Server Error 15517