Database Roles

  • Hello everyone, Is there a way you can REVOKE permissions on a user defined role? like 'SELECT','UPDATE',DELETE','INSERT' instead of on the user level? Thanks!, Pete

    Peter M. Florenzano

    Database Administrator

  • revoke select, update, delete, insert on yourtable from user_defined_role

  • Hi Allen and thank you for the reply. I'm aware of this command on a single table, but is there a way to execute this command with all of my tables in my database, without me going into SQL Server Enterprise Manager to check the boxes in the roles section? I have over 1500 tables. Thanks again, Pete

    Peter M. Florenzano

    Database Administrator

  • select 'revoke select, update, delete, insert on ' + name + ' from user_defined_role ' from sysobjects where xtype = 'U'

    It will generate statements to all your user tables and cut and paste the statements to QA and run them.

     

  • Thank you Allen, I will let you know how it worked!, Pete

    Peter M. Florenzano

    Database Administrator

  • You could also try using the sp_MSforeachtable sproc.  It might be a bit quicker.

    EXEC sp_MSforeachtable @command1 = 'revoke select, update, delete, insert on ? from user_defined_role'

    -------------------------------------------------------------------------
    Normal chaos will be resumed as soon as possible. :crazy:

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply