21

I have created a new login for SQL Server Express as follows:

USE [master]
GO
CREATE LOGIN [Test] WITH PASSWORD=N'SF#$%GD%^J675JFS4fds' 
    MUST_CHANGE, 
    DEFAULT_DATABASE=[master], 
    CHECK_EXPIRATION=ON, 
    CHECK_POLICY=ON
GO

ALTER SERVER ROLE [sysadmin] ADD MEMBER [Test]
GO

USE [master]
GO

CREATE USER [Test] FOR LOGIN [Test]
GO

USE [master]
GO

ALTER ROLE [db_securityadmin] ADD MEMBER [Test]
GO

When I try to connect via the Test login, I receive the error message that

Login failed for user 'Test'

Connect as new Test Login

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467

1 Answers1

64

I needed to configure the server for SQL Server and Windows Authentication Mode.

  1. Open SSMS.
  2. Connect to the server via Windows Authentication.
  3. Right click the server and choose Properties.
  4. Change to "SQL Server and Windows Authentication Mode"

SQL Server and Windows Authentication Mode

See also: http://www.microsoft.com/products/ee/transform.aspx?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • 13
    I also had to restart the SQLEXPRESS service instance after doing the above. – Stafford Williams Sep 25 '15 at 02:25
  • yap, need to restart the sql server after the change! – ken Apr 16 '16 at 08:17
  • I changed this setting and then toiled for hours trying to figure out why it wasn't working, because it doesn't restart the service for you, nor does it even tell you that it needs to restart! Once I saw @StaffordWilliams' comment, I restarted it, and lo and behold it works! Ugh. – daGUY Mar 02 '19 at 18:40
  • I went into services and restarted SQL Server (SQLEXPRESS) services as well as restarting SSMS. – spacebread Mar 21 '19 at 15:23