Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved 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: 423 | Views in the last 30 days: 1
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones