Alterar dbowner SQL Server

Segue script que sempre utilizo para mudar o dbowner dos meus bancos quando necessário.

SELECT 'use '+QUOTENAME(name)+ ' exec sp_changedbowner @loginame =''sa'' ' ,suser_sname(owner_sid)
FROM sys.databases AS d
WHERE [name] NOT IN ('master','TempDB', 'msdb', 'model','DWConfiguration','DWDiagnostics','DWQueue')
AND [name] NOT LIKE 'ReportServer$%'
AND suser_sname(owner_sid) <> 'sa'

Leave a Reply

Your email address will not be published. Required fields are marked *

search previous next tag category expand menu location phone mail time cart zoom edit close