Home Forums Article Discussions Article Discussions by Author Discuss content posted by Sourav Mukherjee Alter database owner to SA from any user details on all user databases RE: Alter database owner to SA from any user details on all user databases
Carolyn Richardson
SSCrazy Eights
Points: 8357
More actions
March 31, 2015 at 4:19 am
#1787618
I would use this where I only want to update non 'sa' owners.
SELECT 'ALTER AUTHORIZATION ON DATABASE::' + QUOTENAME(name) + ' TO [sa];'
FROM sys.databases
WHERE name not in ('master', 'model', 'tempdb')
AND SUSER_SNAME(owner_sid) <> 'sa'
Facts are stubborn things, but statistics are more pliable - Mark TwainCarolynSQLServerSpecialists[/url]