The SQL Swiss Army Knife #1 - Scripting Securables - Updated

Blog do Ezequiel
Portuguese PFE SQL Server Team


Latest Updates
10/05/2014 - Latest update on the AdaptiveIndexDefrag procedure v1.5.8. Look for it in the "Ezequiel shortcuts" section on the right or just click HERE.

10/05/2014 - Updates to Maintenance plan deployment scripts available HERE

04/06/2014 - The SQL Swiss Army Knife Series Index

The SQL Swiss Army Knife #1 - Scripting Securables - Updated

  • Comments 4

EDIT (11-01-2013):  Fixed issue with generating all logins even when single database was chosen.

Hello all,

I've recently joined the PFE team in Portugal, and one part of the job i like is giving something back to the community.
Whenever possible, i will be focusing my posts on SQL scripts that may help on everyday DBA tasks, something in the likes of a "SQL Swiss Army Knife".
According to BOL, SQL securables "are the resources to which the SQL Server Database Engine authorization system regulates access".

I've been using the following script as a "local machine" bit of a wider DR strategy for years, because you never know when you need to quickly review or restore permissions over scopes when they got "accidently" changed or deleted.
Its output may simply be saved onto a .sql file and will resemble this:

usp_SecurCreation

So, for my first post on Ezequiel, here is the script which I hope some of you will find useful.

These are the options available:

  • All users:
    EXEC usp_SecurCreation
  • One user, All DBs:
    EXEC usp_SecurCreation '<User>'
  • One user, One DB:
    EXEC usp_SecurCreation '<User>', '<DBName>'
  • All users, One DB:
    EXEC usp_SecurCreation NULL, '<DBName>'

Download here: usp_SecurCreation_2005_2008.sql

Until next time!

Disclaimer: I hope that the information on these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Ezequiel. Further, Ezequiel shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Social Media Sharing
|
Leave a Comment
  • Please add 1 and 5 and type the answer here:
  • Post
  • Hi Pedro,

    I ran the script but it wrongly assigns EXECUTE permissions to views defined with the Select attribute. It processes views as if they were stored procedures :-O

    Regards

  • Thanks Ignacio,

    It's fixed now. Please try it and give some more feedback.

    Cheers

    PL

  • I've used it today. Thanks! :-)

  • awesome...can we also get permission at table level ?

Page 1 of 1 (4 items)