HGN
HGN

Reputation: 13

SQL Server User table permissions

What is the SQL Server script to create a user and set table permissions to that user?

  1. Create user using script
  2. Set table permissions to that user using script

Upvotes: 1

Views: 1180

Answers (1)

Alireza Maddah
Alireza Maddah

Reputation: 5885

1) Creating a server login:

CREATE LOGIN AbolrousHazem 
    WITH PASSWORD = '340$Uuxwp7Mcxo7Khy';

2) Creating a corresponding database user:

USE AdventureWorks2008R2;
CREATE USER AbolrousHazem FOR LOGIN AbolrousHazem;

3) Granting to select from a table:

GRANT SELECT ON TableName TO AbolrousHazem 

Follow the provided links to get more information.

Upvotes: 2

Related Questions