Re: Script DB Object Level Security with SQL2005
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Wed, 26 Dec 2007 15:39:40 -0800
KevinL (KevinL@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
I see no option to script roles. This is what I did:
Open Management Studio, expand databases, right click the DB, click
Tasks, then Generate Script. The DB I right clicked is highlighted, I
click next. I verified the Script Options to make sure Script
Object-Level Permissions is True (there is no Option that mentions
Roles) and click next. On Object Types window choices are Schema,
Stored Procedures, Tables, User-defined data types, User-defined
functions and Users.
No matter which option(s) I choose, and I've tried every combination I can
think of, Role level permissions are not scripted.
If "Database roles" are not listed, this would indicate that you don't
have any user-defined roles in the database, only the pre-defined roles,
db_owner and the like. Indeed, it appears that membership in these roles
are not scripted.
You can script all role membership with this SELECT:
SELECT 'EXEC sp_addrolemember ''' + r.name + ''', ''' + u.name + ''''
FROM sys.database_role_members rm
JOIN sys.database_principals u
ON rm.member_principal_id = u.principal_id
JOIN sys.database_principals r
ON rm.role_principal_id = r.principal_id
WHERE u.name <> 'dbo'
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- References:
- Re: Script DB Object Level Security with SQL2005
- From: Erland Sommarskog
- Re: Script DB Object Level Security with SQL2005
- From: Erland Sommarskog
- Re: Script DB Object Level Security with SQL2005
- From: KevinL
- Re: Script DB Object Level Security with SQL2005
- Prev by Date: Re: Cannot connect with the Administator account
- Next by Date: Re: Cannot connect with the Administator account
- Previous by thread: Re: Script DB Object Level Security with SQL2005
- Next by thread: Re: Audit Trace Files
- Index(es):
Relevant Pages
|
|