The CREATE USER command in SQL Server

This article will show you in detail how to use the CREATE USER command in SQL Server, with specific syntax and examples to better visualize and capture commands.

This article will show you in detail how to use the CREATE USER command in SQL Server, with specific syntax and examples to better visualize and capture commands.

Describe the CREATE USER command in SQL Server

CREATE USER creates the user database to log into SQL Server. A user database will be mapped to the Login, identifier used to connect to a specific SQL Server instance.

The syntax of CREATE USER command in SQL Server

The CREATE USER command has the following syntax:

 CREATE USER user_name FOR LOGIN login_name; 

Parameters:

  1. user_name: The name of the database user you want to create.
  2. login_name: The Login name is used to connect to a specific SQL Server.

Note:

  1. Before creating a database user, make sure you have created the Login before.
  2. You can only map a Login to a user in each database in SQL Server, but you can also map Login to different user names for each database as long as it is a 1: 1 relationship of Login with a single database.

Example of CREATE USER command in SQL Server

Suppose you want to create a database user named quantrimangcom in SQL Server, and use the previously created Login named qtm as an identifier to connect to a specific SQL Server, we will use the CREATE USER command as follows:

 CREATE USER quantrimangcom FOR LOGIN qtm; 

In the next article we will learn how to change the password in SQL Server.

Previous article: Find Login in SQL Server

Next lesson: Change the password in SQL Server

3.5 ★ | 2 Vote