Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Setting permissions (Updated: UDF's now set)

By tcartwright,

Here is a script I wrote to automate updating of permission on a database. Often running as sa I forget to set the rights for objects when distributing db objects. It provides the capability to process only certain object types, and whether or not to print and execute the persmissions change or just print out the sql to run it later. It also eliminates itself from the permissions list as it would not be good to grant execute on this to [Public].

spSetPermissionsGlobally(@name nvarchar(128) = 'public',
    @printonly bit = 1,
    @revokeOldRights as bit = 1,
    @processViews bit = 1,
    @processProcs bit = 1,
    @processTables bit = 0)


@name - name of the role / user to grant permissions to
@printonly - to print out the sql or print and execute it
@revokeOldRights - whether to revoke all the previous rights for this role
@processViews - Process views?
@processProcs - Process Stored Procs?
@processTables - Process Tables

Total article views: 429 | Views in the last 30 days: 2
 
Related Articles
FORUM

Database Object Permissions Lost

Database Object Permissions Lost

FORUM

execute permission

execute permission

FORUM

Scripting Objects Including Permissions

Scripting Objects Including Permissions

FORUM

ASCMD to process objects

ASCMD to process objects

FORUM

Permissions to execute Assemblies...

Permissions to execute Assemblies...

 
Contribute