How to change db owner after the associated AD account is disabled The new Senior DBA requested that the previous Senior DBA's Active Directory account be disabled. He forgot to check, however, for databases where the previous DBA was the owner. We now have ~60 databases with an orphaned owner. Is there a way to fix this without temporarily re-enabling the disabled AD Account?

Note: I'm aware of best practices regarding not setting the owner to a user. My previous boss probably was too but neglected to make the change everywhere (60 out of thousands isn't as bad as it could have been).
Run this for each database.

   -- Change the database owner
    ALTER AUTHORIZATION ON DATABASE::databasename TO sa;
    GO


To generate the script to change them all:

SELECT 'ALTER AUTHORIZATION ON DATABASE::' + db.name + ' TO sa;'
FROM sys.databases db
WHERE owner_sid != 0x01