This article describes how to define a login in SQL Server
database.
To create a login in a SQL Server database, use the CREATE LOGIN statement followed by the login name and the chosen option.
The most frequently created login forms are those that contain the password.
There are also other options for creating logins, for example create login from a Windows domain account, or create login with multiple arguments.
To create logins, users must have ALTER ANY LOGIN
permission on the server or membership in the securityadmin
.
Create Login syntax
CREATE LOGIN login_name WITH PASSWORD='login_password';
CREATE LOGIN [\] FROM WINDOWS;
CREATE LOGIN [user_name]
WITH PASSWORD = 'login_password',
DEFAULT_DATABASE = database_name,
CHECK_POLICY = { ON | OFF},
CHECK_EXPIRATION = { ON | OFF} ;
Create Login with a password
CREATE LOGIN WITH PASSWORD = '';
GO
Create Login from a Windows domain account
CREATE LOGIN [\] FROM WINDOWS;
GO
Create Login with multiple arguments
CREATE LOGIN [test_user]
WITH PASSWORD = 'test_pass',
DEFAULT_DATABASE = model,
CHECK_POLICY = OFF,
CHECK_EXPIRATION = OFF;