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.
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:
- user_name: The name of the database user you want to create.
- login_name: The Login name is used to connect to a specific SQL Server.
Note:
- Before creating a database user, make sure you have created the Login before.
- 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
You should read it
- DROP USER command in SQL Server
- How to create users in MS SQL Server
- USER_NAME function in SQL Server
- SYSTEM_USER function in SQL Server
- Function SESSION_USER in SQL Server
- CURRENT_USER statement in SQL Server
- How to create a database in MS SQL Server
- How to decentralize users in MS SQL Server
- Find User in SQL Server
- Use the ALTER DATABASE command to migrate DATABASE in SQL Server
- The command changes user in Windows
- Create a new local user account in Windows Server 2016
Maybe you are interested
This is the culprit that prevents users from updating Windows 11 24H2
How to switch users on the Linux command line
4 reasons why users are looking forward to the Samsung Galaxy S25 Ultra
5 things Pro users may have to give up to switch to iPhone 17 Air
Mozilla quietly adds user tracking feature in new Firefox update
8 Windows 11 features that make users decide to give up Windows 10