Table level permission

  • Hello,

    I would like to give read/write permission to a handful of tables in a database. Do I just use something like:USE MyDatabase;

    GO

    GRANT DELETE ON MyTable1 TO WindowsGroup;

    GO

    GRANT INSERT ON MyTable2 TO WindowsGroup;

    GO

    ...

    Notice that they do not need UPDATE.

    I can create a login on the instance and give r/w to the database but that is more than I really want to give, as there are tables they should not touch. Not that they would know how to access any of the tables, but why leave it open.

    Questions:

    1) Do I leave the instance logins or do I change them?

    2) If I change the instance logins what would the change be?

    3) Do I GRANT the privilege as above for each table?

    4) What about execute of stored procedure? - This is most likely not needed.

    The data is coming from a stored procedure from a different server/instance of SQL server. I tried EXECUTE AS but was unsuccessful, with the message saying the login did not exist or did not have permissions. I need to look into this but needed a quick fix for now.

  • If I understand this correctly, you have one instance A where some stored procedure inserts and deletes rows in a database on instance B by means of direct INSERT and DELETE statements with four-part notation. Now you are looking to how to solve the permissions on server B.

    Seen from the perspective of server B, this scenario is no different from the users connecting directly from SSMS to run INSERT and DELETE statements. (Unless you set up a login-mapping on server A, but this has other issues.)

    It is difficult to answer the questions what you should do with the instance logins, because I don't understand what the problem might be. But then again, I don't know your site. However, the paragraph above may give a clue: this is the same as direct access from SSMS or whatever.

    You should of course not grant access directly to users, but to an SQL Server Role or a Windows group, but you seem to have grasped that already.

    The GRANT statements would be those you listed, and you are right in granting minimal amount of permissions.

    For the question about stored procedures, I am again puzzled why you ask. Is something more hiding here?

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • Erland Sommarskog (6/25/2014)


    If I understand this correctly, you have one instance A where some stored procedure inserts and deletes rows in a database on instance B by means of direct INSERT and DELETE statements with four-part notation. Now you are looking to how to solve the permissions on server B.

    Seen from the perspective of server B, this scenario is no different from the users connecting directly from SSMS to run INSERT and DELETE statements. (Unless you set up a login-mapping on server A, but this has other issues.)

    It is difficult to answer the questions what you should do with the instance logins, because I don't understand what the problem might be. But then again, I don't know your site. However, the paragraph above may give a clue: this is the same as direct access from SSMS or whatever.

    You should of course not grant access directly to users, but to an SQL Server Role or a Windows group, but you seem to have grasped that already.

    The GRANT statements would be those you listed, and you are right in granting minimal amount of permissions.

    For the question about stored procedures, I am again puzzled why you ask. Is something more hiding here?

    Thank you for the reply.

    The stored procedure is not really a problem just me thinking about possible problems while writing without thinking about it. :hehe:

    For the main instance DB1 the user has permission through group wingroup1. On the second instance DB2 (which is called using the four-part notation) they had no permissions so I temporarily gave wingroup1 permission to the database. I will be taking that away today and giving the group GRANT permissions as suggested.

    I seem to muddle though security and get confused when reading anything written by Microsoft on the subject. I find forums help there or maybe a good white paper. Since we do not need to adjust security very often, I do not work with it enough to remember all the ins and outs.

    Thanks again,

    djj

  • For the main instance DB1 the user has permission through group wingroup1. On the second instance DB2 (which is called using the four-part notation) they had no permissions so I temporarily gave wingroup1 permission to the database. I will be taking that away today and giving the group GRANT permissions as suggested.

    Eh, they must of course be able to connect to the database. I don't know exactly what you mean with "gave permssion", but if you said "CREATE USER [Domain\Wingroup1]" you should not back out that.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • Erland Sommarskog (6/26/2014)


    Eh, they must of course be able to connect to the database. I don't know exactly what you mean with "gave permssion", but if you said "CREATE USER [Domain\Wingroup1]" you should not back out that.

    By gave permission I went to DB2\Security\Logins and right clicked choosing New Login...

    After selecting the group I then went to "User Mapping"

    For the database I checked Map then checked db_datareader and db_datawriter permission (leaving public).

  • You should keep the login and the group as a user. But you should drop the group from db_datawriter and db_datareader.

    Which version (including service pack) does this server have?

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

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

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