Permissions to 100+ tables

  • Hi Experts,

    which is the best way to give user permission to 100+ tables?

    Is it by creating roles and adding the same to particular tables

    or

    Adding user to each tables

    or

    IS THERE ANY OTHER BETTER WAY TO ACHIEVE THE SAME?

    CAN WE GIVE PERMISSIONS TO MULTIPLE TABLES IN A GO?

    Thanks in Advance.

  • to give permissions to all tables and views use the roles

    DB_Datareader

    DB_Datawriter

    or just create scripts to grant the permissions to the tables (remove un needed permissions as required)

    GRANT SELECT, INSERT, DELETE, UPDATE ON OBJECT::dbo.mytable1 TO user_or_role

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • The best way is to grant the permissions to a user role. Add the user or group to that role.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thanks Everyone

  • CirquedeSQLeil (4/28/2010)


    The best way is to grant the permissions to a user role. Add the user or group to that role.

    TO user_or_role

    😉

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Ratheesh.K.Nair (4/28/2010)


    Thanks Everyone

    You're welcome.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • you can even do something like this:

    SELECT 'GRANT SELECT ON '+quotename(table_name)+' to '+'Maninder' FROM Information_Schema.Tables

    WHERE Table_Type='BASE TABLE'

  • Maninder S. (4/30/2010)


    you can even do something like this:

    SELECT 'GRANT SELECT ON '+quotename(table_name)+' to '+'Maninder' FROM Information_Schema.Tables

    WHERE Table_Type='BASE TABLE'

    don't forget to include the schema and use

    SELECT'GRANT SELECT ON [' +

    s.name + '].[' +

    t.name + '] to ' + 'Maninder'

    FROM sys.tables t inner join sys.schemas s

    on t.schema_id = s.schema_id

    WHERE t.type = 'U'

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • An alternative syntax to achieve the same for all tables and views in a schema would be:

    GRANT SELECT ON SCHEMA:DBO TO user_or_role_namehere;

Viewing 9 posts - 1 through 8 (of 8 total)

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