I have a domain with the name test.com and I have a simple query to add an account from this domain to the SQL Server Logins:
CREATE LOGIN [test.com\MyUser] FROM WINDOWS WITH DEFAULT_DATABASE=[DB];
But for some reason it fails with the error Windows NT user or group 'test.com\MyUser' not found. Check the name again..
When I specify the domain name without '.com' it works:
CREATE LOGIN [test\MyUser] FROM WINDOWS WITH DEFAULT_DATABASE=[DB];
What is the reason and how to make it working for both queries?
CodePudding user response:
Please, read this documentation: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-login-transact-sql?view=sql-server-ver15
"When you are creating logins that are mapped from a Windows domain account, you must use the pre-Windows 2000 user logon name in the format domain_Name\login_name"
And "domainName" refers to Windows domain, which is not in "test.com" format.
