How to create users in MS SQL Server

The user here is an account on MS SQL Server to access the database (database).

The user here is an account on MS SQL Server to access the database (database).

Users can be created in 1 of 2 ways below.

Method 1: Use T-SQL

Syntax for creating users in MS SQL Server.

 Create user for login 

For example:

To create a user named TestUser with the login name TestLogin on TestDB database , run the query below.

 create user TestUser for login TestLogin 

Method 2: Use SQL Server Management Studio SSMS

Note: First, you need to create Login with any name before creating user account. Use Login as TestLogin.

Step 1 : Connect to SQL Server and expand the database directory. Then open the database named TestDB, where we will create user accounts, find the Security folder . Find the Users or Logins folder (on the new SQL Server version) and select New Login. Then the screen below will appear.

How to create users in MS SQL Server Picture 1How to create users in MS SQL Server Picture 1
New user creation screen for MS SQL Server

Step 2: Enter the TestUser name for the username and select the Login name named TestLogin as shown below.

How to create users in MS SQL Server Picture 2How to create users in MS SQL Server Picture 2
Create a new user account

Step 3: Click OK to finish. Refresh the folder, you will see the newly created username.

How to create users in MS SQL Server Picture 3How to create users in MS SQL Server Picture 3
Successfully created new users on MS SQL Server

Previous article: How to recover the database in MS SQL Server

Next lesson: How to decentralize access in MS SQL Server

4 ★ | 1 Vote