This scripts changes the ownership of all non-system databases on a SQL Server instance to the 'sa' user.
SQL Server 2005+
EXEC sp_MSForEachDB
'Use ?;IF DB_ID() > 4 AND DB_NAME() <> ''distribution'' EXEC sp_changedbowner ''sa'''
blog comments powered by Disqus