I am new to sqlcmd and I want to create a new user. I have done the following:

2> go
2> go

Then from cmd prompt I ran the following:

sqlcmd -s LOCALHOST -U 'FYI_DBA' -P 'V_2017'
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user ''FYI_DBA''..

What am I doing wrong?

  • What do you see in the SQL error log? – SqlWorldWide Apr 12 '17 at 0:30

Check that your SQL Server allows SQL authentication. By default it will be windows authentication only. You can check the SQL Server errorlog which will provide the login failure reason.

The message I you would see in the log in that situation would be

Login failed for user 'FYI_DBA'. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only. [CLIENT: ]

You can change the authentication type using the GUI or T-SQL

  • Besides what Nic mentioned above you also have to what @Tara Kizer mentioned in other answer. Remove single quotes. I just test it. Are you sure that login and user got created? I am asking because you are using a weak password. – SqlWorldWide Apr 12 '17 at 0:24
  • This did the trick – user1871528 Apr 12 '17 at 1:23

Remove the single quotes around the values for -U and -P.

sqlcmd -s LOCALHOST -U FYI_DBA -P V_2017

  • I ran the above command, I got the same exact error – user1871528 Apr 11 '17 at 22:25
  • See Nic's answer then. – Tara Kizer Apr 11 '17 at 22:39
  • @Tara Kizer you were right. Will need to do both or login did not get created due weak password? – SqlWorldWide Apr 12 '17 at 0:30
  • SqlWorldWide you are absolutly right. I had to do what Nic suggested then I had to remove the quotation as Tara suggested. – user1871528 Apr 12 '17 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.