Tony_Henrich
Tony_Henrich

Reputation: 44075

Incorrect syntax near.. in SQL Server Statement

Why is this giving a "Incorrect syntax near 'master'" error? I put master in square brackets also.

CREATE LOGIN SQLDBA with DEFAULT_DATABASE = master

Upvotes: 0

Views: 2364

Answers (2)

Bavithra Mohan
Bavithra Mohan

Reputation: 21

If you are going to create a domain user use the below

USE [master]
GO
CREATE LOGIN [test_user] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO

If you are going to create a internal user use the below

USE [master]
GO
CREATE LOGIN [test_user] WITH PASSWORD=N'Welcome@123' MUST_CHANGE, 
DEFAULT_DATABASE=[master], CHECK_EXPIRATION=ON, CHECK_POLICY=ON
GO

CHECK_EXPIRATION, CHECK_POLICY, MUST_CHANGE values are given based on the requirements

Upvotes: 0

Jayasurya Satheesh
Jayasurya Satheesh

Reputation: 8033

This might be because you have not specified the password for the user. try the below

CREATE LOGIN SQLDBA with PASSWORD=N'YCm3zAe1qoheDTFiEJDiLDOt/WJ0tdd4//ag6YbL1LE=',DEFAULT_DATABASE = [master]

The password will be 1234

Upvotes: 2

Related Questions