Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also recently deleted my windows account from my local development 2008 server. I was able to use SQL server's Single User Mode to recreate my login and add it to the sysadmin role. It took just a few minutes, and I didn't have to admit my terrible error to anyone.</p> <p>From MSDN:</p> <blockquote> <p>Starting SQL Server in single-user mode enables any member of the computer's local Administrators group to connect to the instance of SQL Server as a member of the sysadmin fixed server role.</p> </blockquote> <p>Here's how I reinstated myself:</p> <ol> <li>Exit out of SSMS</li> <li>Stop any SQL related services. I had to stop Reporting Services. Other SQL services such as SQL Agent will also use up your one, valuable connection.</li> <li>Stop the SQL service </li> <li>Start the SQL service with the extra parameter <code>-m</code>. This will put the SQL into Single User Mode. This means that SQL will only accept one connection. </li> <li>Use <code>sqlcmd</code> to connect to your server with the <code>-E</code> trusted connection option. SQL will accept you into the <code>sysadmin</code> role if you're a local administrator.</li> <li><p>In the interactive session, create your login and add to the <code>sysadmins</code> role. </p> <pre><code>USE master GO CREATE LOGIN [domain\username] FROM WINDOWS WITH DEFAULT_DATABASE=[Master] GO EXEC sp_addsrvrolemember @loginame=N'domain\username', @rolename=N'sysadmin' GO </code></pre></li> <li>Stop the SQL service, remove the <code>-m</code> parameter and restart the service. You should now be able to go back into SSMS and continue using the server normally.</li> </ol> <p>If you get the message:</p> <blockquote> <p>Login failed for user 'domain\username'. Reason: Server is in single user mode. Only one administrator can connect at this time.</p> </blockquote> <p>Then there is something using your single connection. You'll need to find that service or connection and stop it before you can log in. Check SQL Agent, SQL Reporting Services, SQL Analysis Services etc.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload