English 中文(简体)
MS SQL Server - Assign Permissions
  • 时间:2024-12-22

MS SQL Server - Assign Permissions


Previous Page Next Page  

Permissions refer to the rules governing the levels of access that principals have to securables. You can grant, revoke and deny permissions in MS SQL Server.

To assign permissions either of the following two methods can be used.

Method 1 – Using T-SQL

Syntax

Use <database name>
Grant <permission name> on <object name> to <usernameprinciple>

Example

To assign select permission to a user called TestUser on object called TestTable in TestDB database, run the following query.

USE TestDB
GO
Grant select on TestTable to TestUser

Method 2 – Using SSMS (SQL Server Management Studio)

Step 1 − Connect to instance and expand folders as shown in the following snapshot.

Assign Permissions

Step 2 − Right-cpck on TestUser and cpck Properties. The following screen appears.

Database TestUser

Step 3 Cpck Search and select specific options. Cpck Object types, select tables and cpck browse. Select TestTable and cpck OK. The following screen appears.

Database TestUser

Step 4 Select checkbox for Grant column under Select permission and cpck OK as shown in the above snapshot.

Database TestUser

Step 5 Select permission on TestTable of TestDB database granted to TestUser . Cpck OK.

Advertisements