Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server - Permission on a per table basis?

Tags:

sql

sql-server

I have a .net where I only have read access to the SQL Server database. Is it possible for SQL Server to give me write access to just ONE of the tables in the database, and restrict me to read only for the rest of the database?

like image 306
John Avatar asked Apr 11 '11 15:04

John


People also ask

How do I give access to a specific database in SQL Server?

Right-click on Logins and select New. Enter the username. To set permissions, double-click the user account and do one of the following: If you are using SQL Authentication, enter the user name.

How do I get a list of users access to a table in SQL Server?

database_principals view. The sys. database_principals is a system catalog view available in SQL Server, and we can easily query this view to list all the users created in the database.


1 Answers

Use this TSQL script, if you need:

EXEC sp_addrolemember N'db_datareader', N'User1';

GRANT INSERT, UPDATE, SELECT ON 
   MyTable 
TO User1 --for multiples, it's   TO User1,User2
like image 166
p.campbell Avatar answered Oct 18 '22 05:10

p.campbell