Yes, this SQL Server error 471 occurs because you tried to create a user or login but did not specify a valid authentication mode (SQL Authentication, Windows Authentication, or Mixed Mode). To fix it, you must use the correct syntax to create the user, specifying the login name, password, and the correct authentication type, or use the CREATE USER command with the FOR LOGIN clause to map the user to an existing login. This guide explains the error, why it happens, and provides the precise steps to resolve it.
What You'll Need
- A working installation of Microsoft SQL Server Management Studio (SSMS) or a similar query tool connected to your database.
- Administrative rights (sysadmin or securityadmin server role) to create logins and users. Regular users cannot create new logins.
- Network connectivity to the SQL Server instance.
- Knowledge of the authentication mode your database server uses (Windows-only or Mixed Mode).
Understanding the Error
Error 471 is a fairly straightforward syntax error. It is often triggered when a developer or administrator attempts to create a SQL Server user using the CREATE USER statement but omits the critical component that tells the server how to authenticate that user. In earlier versions of SQL Server, the CREATE USER command often defaulted to Windows Authentication, but in modern versions, the database engine is more strict.
The error message typically reads: "Error 471: Only one of the three options single, database_role_name, or login_name may be specified."
This message is a direct instruction from the database engine. It is telling you that in the CREATE USER statement you just ran, you provided more than one of these three valid options, or none of them, in a way that is not supported. You cannot combine options like WITH PASSWORD (which implies a SQL login) and FROM LOGIN (which implies Windows authentication) in a single line without properly structuring the statement.
Step-by-Step Resolution
The fix depends on whether you want to create a new login (SQL Authentication) or map an existing login (Windows Authentication) to a database user.
Scenario A: Creating a New SQL Login (SQL Authentication)
If you need a user that connects with a username and password (SQL Authentication), you must create a login first, and then create a user for that login. You cannot create the user directly with a password in one step without the login existing.
- Open SSMS and connect to your SQL Server instance using an account with administrative privileges.
- Open a New Query Window by clicking the "New Query" button in the toolbar or pressing
Ctrl+Shift+N. - Verify Server Authentication Mode. Ensure your server is running in Mixed Mode (SQL Server and Windows Authentication mode), otherwise, SQL Authentication logins cannot be created. You can check this by right-clicking the server name in the Object Explorer, selecting "Properties", and going to the "Security" page.
- Run the CREATE LOGIN Statement. In the query window, type the following command to create the login. Replace
MyNewUserwith your desired username andStrongPassword123!with a secure password. - Verify the Login was Created. Look at the Object Explorer on the left side of the window. Expand the "Security" folder, then expand "Logins". You should see your new login listed there.
- Create the Database User. Now, create the user that maps to this login. Type the following command into the query window:
- Run the Query by pressing
F5. The command should execute successfully without error 471. - Grant Permissions (Optional). If the user needs to read data, you can grant the
SELECTpermission. If they need to write data, you can grantINSERT,UPDATE, andDELETE. For example:
CREATE LOGIN [MyNewUser] WITH PASSWORD = 'StrongPassword123!';
CREATE USER [MyNewUser] FOR LOGIN [MyNewUser];
GRANT SELECT ON SCHEMA::dbo TO [MyNewUser];
Scenario B: Mapping an Existing Windows User
If you want to create a user for a Windows domain account (like DOMAIN\JohnDoe), you do not need to create a login first. You can create the user directly, provided the login already exists on the server.
- Open SSMS and connect to your SQL Server instance.
- Open a New Query Window.
- Determine the Login Name. You must know the exact format of the Windows login. This is usually in the format
DOMAIN\Username. Ensure this login has already been created in the server's Security > Logins folder. - Run the CREATE USER Statement. Type the following command, replacing the placeholder with your actual domain and username:
- Run the Query by pressing
F5. This creates the database user without triggering error 471.
CREATE USER [DOMAIN\JohnDoe] FOR LOGIN [DOMAIN\JohnDoe];
Common Mistakes
Understanding why developers encounter this error repeatedly is key to avoiding it. Here are the most frequent mistakes:
- Combining Password with Login Name. A common syntax error is trying to create a user with a password and a login name in one line, such as
CREATE USER [NewUser] WITH PASSWORD='pass' FOR LOGIN [NewUser];. This is invalid syntax. You must create the login first, then the user. - Missing Brackets. If your username contains special characters or spaces, SQL Server requires the name to be enclosed in square brackets
[]. Forgetting these brackets can cause parsing errors that look like error 471. - Using the Wrong Clause. Using
WITH PASSWORDimplies you are creating a SQL login. UsingFOR LOGINimplies you are mapping an existing login. You cannot useWITH PASSWORDwithout also creating the login in a separate step. - Creating a User Without a Login. In some configurations, you cannot create a user without linking it to a login. Attempting to create a user without the corresponding login will often result in error 15025 or 15023, which are related but distinct from error 471.
Tips for Success
- Always Check the Object Explorer. Before running complex commands, visually confirm that the necessary login exists in the Security > Logins folder.
- Use Secure Passwords. Always use strong, complex passwords for SQL Authentication logins. Avoid using passwords that are easy to guess or that contain dictionary words.
- Enclose Names in Brackets. Get into the habit of always wrapping database object names in square brackets, especially when they contain spaces or special characters. This prevents syntax errors.
- Check Server Authentication Mode. If you are trying to create a SQL login but keep getting an error stating that the login creation failed, your server might be locked down to Windows Authentication only. You will need an administrator to change the server property.
- Use the Correct Schema. When creating a user, they are often assigned to the
guestschema by default. If you want them to work with your application's tables, consider assigning them to thedboschema usingALTER USER [MyUser] WITH DEFAULT_SCHEMA = dbo;.
Troubleshooting
If you have followed the steps above and still encounter issues, proceed with these checks.
Issue: The Login Already Exists
If you try to create a login that already exists, SQL Server will throw error 15023. Before creating a new login, check if it exists by looking in the Object Explorer or running the query SELECT name FROM sys.server_principals WHERE type = 'S'; (for SQL logins).
Issue: Permission Denied
If you receive an error stating you do not have permission to create the login, you are not connected with a user that has the required privileges. You must connect using a Windows account that is a member of the sysadmin server role or the securityadmin server role.
Issue: Cannot Find the Login Name
If you are trying to create a user for a Windows login but get an error that the login cannot be found, double-check the spelling and the backslash separator. It must be DOMAIN\Username, not DOMAIN/Username or DOMAIN.Username.
Issue: Error 471 Persists
If you are certain you are using the correct syntax, the issue might be with your query editor. Close the query window and open a new one. Sometimes, hidden characters or corrupted query buffers can cause unexpected parsing errors. If the error persists, copy your code into a text editor like Notepad to ensure it is clean, then paste it back into SSMS.
Frequently Asked Questions
What does Error 471 mean exactly?
Error 471 means that in your CREATE USER or CREATE LOGIN statement, you provided more than one valid option (like a login name, a database role name, or the word 'single') that the database engine does not allow to be combined in that specific way, or you provided an invalid combination.
Can I create a user with a password directly?
No. You cannot create a user with a password in a single step. You must create the login with the password first, and then create the user that maps to that login.
Do I need to create a user for every login?
No. If you have a Windows login, you can create a user for it directly. However, it is best practice to create a user for every login because it allows you to control database-level permissions more granularly than server-level permissions.
What is the difference between a login and a user?
A login is a server-level credential that authenticates a user to the SQL Server instance. A user is a database-level object that allows that authenticated user to access a specific database. You need both to access a database.
How do I check if my server is in Mixed Mode?
Right-click the server name in Object Explorer, select Properties, and go to the "Security" page. If "SQL Server and Windows Authentication mode" is selected, your server is in Mixed Mode.
Why am I getting an error about the login not existing?
This usually happens when you use the FOR LOGIN clause but the login has not been created yet, or you misspelled the login name. Ensure the login exists in the Security > Logins folder before creating the user.