Results 1 to 5 of 5

Thread: Permission using T-SQL

  1. #1
    Join Date
    May 2003
    Posts
    30

    Unhappy Permission using T-SQL

    I have a database with over 100 tables. I need to add a user with deny permission on all tables except one. Is there a way of doing this without having to enter the names of all the tables and not using EM and ticking over 100 boxes? I tried to write the script using a select from sysobjects where xtype = 'U' but it didn't like it very much!!

    Any help would be greatfully appreciated.

    Many thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    The only thing need to do is leave the user in public role only and grant permission on that table either in em or with grant statement.

  3. #3
    Join Date
    May 2003
    Posts
    30

    Exclamation

    Thanks for that, but I would have thought that if Public had select on all tables, by default my new user would. If I give public deny on all tables that will overwrite any permissions given on the individual login as deny supercedes any select. Maybe I'm missing something here.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Public role doesn't have any permission on user tables by default.

  5. #5
    Join Date
    Feb 2003
    Posts
    1,048
    Select 'Deny All On [' + Table_Schema + '].[' + Table_Name + '] To UserAccount'
    From Information_Schema.Tables
    Where Table_Type = 'BASE TABLE'
    And Table_Name <> 'dtproperties'
    And Table_Name <> 'The table to which I want to allow access'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •