Re: How do I script out all the permmisions granted to a database role



Tony
Aaron wrote this script
CREATE FUNCTION dbo.RoleCheckUser
(
@UserName sysname,
@RoleName sysname
)
RETURNS BIT
AS
BEGIN
DECLARE @RetVal BIT
SET @RetVal = 0

SELECT @RetVal = 1
WHERE EXISTS
(
SELECT *
FROM sysmembers membs
JOIN sysusers users on membs.memberuid = users.uid
JOIN sysusers groups on membs.groupuid = groups.uid
WHERE
users.name = @UserName
AND groups.name = @RoleName
)

RETURN @RetVal
END
GO

-- Syntax to use the created function
SELECT dbo.RoleCheckUser('dbo', 'db_owner')
GO
"Tony C" <TonyC@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FA1B80AC-34C2-49EE-9C72-84775408565D@xxxxxxxxxxxxxxxx
How do I script out all the permmisions granted to a database role. When
moving database roles to my production environment I need clean way to
script
out all securables (tables, views and procedures, etc...) and the rights
granted to them for this role. Logins assigned to the role would be
helpful
also. I don't see a way to script these out or report on them. Is there
a
way to do this? I am familiar with listing the properties for the role,
and
listing the explicit permissions on the securable tab within manangement
studio. But this is very manual. If I script out the database role by
right
clicking it, I only get the create role statement with none of the object
rights or logins granted to this role.
Thanks
Tony


.



Relevant Pages

  • Re: OBJECT Level Permissions
    ... DECLARE @username SYSNAME ... Run in Query Analyzer with Text output to generate a script, ... save the script at your convenience. ... What is the best way to GRANT EXEC permissions on "all" my stored ...
    (microsoft.public.sqlserver.programming)
  • Re: Vista hosting XPe tools/db
    ... Copyright Microsoft Corporation. ... All rights reserved. ... you can run setsqlperms.vbs script as follows: ... machine hosting the database. ...
    (microsoft.public.windowsxp.embedded)
  • RE: Using SMS to install network printers
    ... - When it spawns it has to have appropriate rights. ... directory from a command line and run the batch file. ... You might have to tweak your script a bit for error ... > cscript SCRIPTNAME.VBS ...
    (microsoft.public.sms.misc)
  • Re: having problems trying to activate a movie from an online stor
    ... See http://zachd.com/pss/pss.html for some helpful WMP info. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... an error has occurred in the script on this page. ... contact microsoft product suport. ...
    (microsoft.public.windowsmedia.player)
  • Re: Superman and the Secret Planet -- Great stuff!
    ... to rights issues in the broadest sense. ... script would be less expensive and time consuming to acquire the ... As for it not being in-house, they recently bought a Wonder Woman ... that Gillis script to life so well, on Nolt's site these last several ...
    (rec.arts.sf.superman)