Search code examples
sql-serversqlcmd

SQL Server 2008 in single-user mode allows no connections


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?


Solution

  • 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.