Tuesday, December 16, 2014

Adding bulk rights for users

This really needs to be modified to eliminate the system DBs but I don't have time right now to add it:


EXEC sp_MSForEachDB 'Use ?; exec sp_changedbowner sa'

EXEC sp_MSForEachDB 'ALTER DATABASE ? SET RECOVERY SIMPLE;'

EXEC sp_MSForEachDB 'ALTER DATABASE ? SET COMPATIBILITY_LEVEL = 110;'


EXEC sp_MSForEachDB 'Use ?; CREATE USER [DOMAIN\User_or_Group] WITH DEFAULT_SCHEMA = dbo;'

EXEC sp_MSForEachDB 'Use ?; ALTER ROLE db_owner ADD MEMBER  [DOMAIN\User_or_Group];'

No comments: