T-SQL Tutorial

T-SQL Create User


This article describes how to define a new user in SQL Server database.
The T-SQL statement CREATE USER defines user in the current database.



Create User syntax

CREATE USER user_name;
CREATE USER user_name WITH PASSWORD = user_pass;
CREATE USER user_name FOR LOGIN [DomainName\WindowsUser];
CREATE USER user_name FROM LOGIN [DomainName\WindowsUser];


Create User example

GO
CREATE USER test_user FOR LOGIN [DomainName\WindowsUser];
GO
CREATE SCHEMA test_schema
GRANT SELECT ON SCHEMA::test_schema TO test_user
GO