I’m trying to make a basic, plain-text password login and database user for a locally running instance of SQL Server 2008. I’m using the following SQL code to make the logins, add the user, and give permissions, but I cannot connect to the server with SSMS or SQLCMD (which works fine when I use my domain credentials and Integrated Security).
USE <database_name>
GO
CREATE LOGIN aspLogin with password=N'pass1',
DEFAULT_DATABASE=<default_db>, CHECK_POLICY = OFF
GO
CREATE USER aspLogin FOR LOGIN aspLogin
EXEC sp_addrolemember N'db_datareader', N'aspLogin'
EXEC sp_addrolemember N'db_datawriter', N'aspLogin'
GO
USE master
GO
GRANT CONNECT SQL TO aspLogin
Using SQLCMD:
C:\>sqlcmd -S .\SQL -P pass1 -U aspLogin
Msg 18456, Level 14, State 1, Server <machine_name>\SQL, Line 1
Login failed for user 'aspLogin'.
What am I missing? Is this a problem with using “.\SQL” (which is the correct name of the instance, not the default instance name). For example, this works fine:
C:\>sqlcmd -S .\SQL -E
1>
Make sure mixed mode authentication is enabled.
http://msdn.microsoft.com/en-us/library/ms188670(v=sql.105).aspx
You can easily check the authentication mode using