6

I don't know the SA password so I restarted my SQL Server 2008 Standard Edition instance in Single-user mode with the hope of changing the SA password. Immediately afterwards I tried connecting with

sqlcmd -S serverName\ss2008

Msg 18461, Level 14, State 1, Server serverName\SS2008, Line1 Login failed for user 'serverName\Administrator'. Reason: Server is in single user mode. Only one administrator can connect at this time.

My attempts at changing the password right out yields

C:\Documents and Settings\Administrator>sqlcmd -U sa -z p@ssword Password: Msg 18470, Level 14, State 1, Server serverName, Line 1 Login failed for user 'sa'. Reason: The account is disabled.

Does -m really stand for zero-user mode, or is there something horribly awry with my server?

Blanthor
  • 2,568
  • 8
  • 48
  • 66

1 Answers1

8

Your connection may be being taken immediately by some other service (e.g. SQL Agent, Reporting Services)

You can pass an optional additional client name parameter with the -m switch.

e.g. using

-m"sqlcmd"   

Will only permit the single available connection to be taken by a program that identifies itself as the sqlcmd client program. See the docs for more about this.

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
  • 3
    This is good information. I also made the mistake of not explicitly setting the correct account on the "Log On" tab when I started the service in the Sql Server Configuration Manager. This has to be the same account as you're using with sqlcmd. This might be obvious, but alas not to me. – Blanthor May 29 '12 at 19:40
  • Also, try running Management Studio as Administrator. I followed this and it works: http://technet.microsoft.com/en-us/library/dd207004.aspx – Richard Jun 26 '13 at 11:23