SQL Database Tools - Owner

--Database owners SELECT suser_sname( owner_sid ), * FROM sys.databases --Databases with specific owner SELECT name from sys.databases where SUSER_SNAME(owner_sid) = 'sa'\ --Script out change db owner on all DBs SELECT ' --if (@@servername = '''+@@servername+''') --use if logged into multiple servers and need to change owners on all ALTER AUTHORIZATION ON DATABASE::' + QUOTENAME(name) + ' TO [DB_OWNER];' from sys.databases where name not in ('master', 'model', 'tempdb', 'msdb', 'distribution') AND suser_sname(owner_sid) != 'DB_OWNER' --AND suser_sname( owner_sid ) LIKE 'DOMAIN\%' -- all windows auth users --OR Change owner using below for now --**** EXEC sp_changedbowner [DB_OWNER]; --*** WILL BE DEPRECATED

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.