SQL server unable to create user with dash in domain name I am in the process of creating a proxy user in SQL server. I run the below SQL but it failed with the error because my domain name has dashes in it.

CREATE LOGIN [ABC-SEN-DEA\proxyssisuser] WITH PASSWORD='Password'



  Msg 15006, Level 16, State 1, Line 1
  'ABC-SEN-DEA\proxyssisuser' is not a valid name because it contains invalid characters.


Please help how to rectify this error.
You have a misconception in your thoughts. A Windows login which is used to create a SQL Server login does not require a password.

Solution

When you create a SQL Login using a Windows account you have to use a different syntax.

CREATE LOGIN [ABC-SEN-DEA\proxyssisuser] 
FROM WINDOWS 
WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO


Reference: CREATE LOGIN (Transact-SQL) (Microsoft)

Explanation

When you link a Windows login with SQL Server, the SQL Server will trust the Windows login which has already been validated by the account logging in to the Windows system.

The chapter Connecting Through Windows Authentication in the article Choosing an Authentication Mode explains how Windows Accounts login to a SQL Server instance: 


  When a user connects through a Windows user account, SQL Server validates the account name and password using the Windows principal token in the operating system. This means that the user identity is confirmed by Windows. SQL Server does not ask for the password, and does not perform the identity validation. Windows Authentication is the default authentication mode, and is much more secure than SQL Server Authentication. Windows Authentication uses Kerberos security protocol, provides password policy enforcement with regard to complexity validation for strong passwords, provides support for account lockout, and supports password expiration. A connection made using Windows Authentication is sometimes called a trusted connection, because SQL Server trusts the credentials provided by Windows.


Good luck.