Created
May 13, 2022 16:22
-
-
Save Otterpohl/c42e51d63e35b940e350ad175ea37309 to your computer and use it in GitHub Desktop.
Revisions
-
Otterpohl created this gist
May 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ SELECT 'ALTER AUTHORIZATION ON DATABASE::' + QUOTENAME(d.[name]) + ' to sa' FROM [sys].[databases] d INNER JOIN [sys].[server_principals] s ON s.sid = d.owner_sid WHERE d.[name] NOT IN ('master','msdb','model','tempdb') AND s.[name] <> 'sa'