This SQL Server tutorial explains how to use the SQL Server CREATE USER statement with syntax and examples.
The CREATE USER statement creates a database user to log into SQL Server. A database user is mapped to a Login, which is an identity used to connect to a SQL Server instance.
The syntax for the CREATE USER statement in SQL Server (Transact-SQL) is:
CREATE USER user_name FOR LOGIN login_name;
Parameters or Arguments
The name of the database user that you wish to create.
The Login used to connect to the SQL Server instance. Learn how to create a Login.
- Before creating a database user, make sure that you have first created a Login.
- You can only map a Login to one user in each database in SQL Server, but you can map the Login to different user names for each database as long as it is a 1:1 ratio of Login to unique database.
- See also the DROP USER statement.
Let’s look at how to create a database user using the CREATE USER statements in SQL Server (Transact-SQL).
CREATE USER adglob FOR LOGIN adglob;
This CREATE USER example would create a new database user called adglob in SQL Server. It would use the adglob Login as the identity to connect to the SQL Server instance.