I'm trying to give access to an active directory user to only one specific table. I want them to be able to insert, update, delete, etc. but only for that table. I know this command:
GRANT Insert, Select on Tablename to user
But I can't figure out how to get "domain\user" to work syntax-wise. I tried:
GRANT Insert, Select on Tablename to domain\user
But I get:
Msg 102, Level 15, State 1
Incorrect syntax near '\'.
Assuming you have created a user in this database associated with the AD login, e.g.
Then you merely have to follow the same syntax. Because
\
is not a standard character for an identifier, you need to escape the name with[square brackets]
:It is a good practice to create a role and add users to that role. Then grant permissions to that role.