Regain Control of your local SQL Server

I recently had a domain account removed and later recreated. I got my old machine back but noticed I had lost access to SQL SERVER. I had originally installed SQL with my domain account, so that account was the only “sysadmin” in SQL. With that account having been deleted, I had lost control of SQL.

After some googling I found a solution that has given me control back. You have to run SQL in “single user mode” this option pretty much makes any “Local Admin” a “sysadmin” in SQL, than giving you the rights to add your new account as a sysadmin. Apparently previous versions of SQL would always allow “Local Admins” access, but that is not the case with the latest versions of SQL.  Since I am currently running BizTalk 2009, it means I am using SQL Server 2008.

For more information: http://msdn.microsoft.com/en-us/library/ms188236(v=SQL.105).aspx

You will first have to stop all instances of SQL Server, plus the SQL Server Agent. So I just went ahead and stopped all SQL Related Services.

  1. Start | Microsoft SQL Server 2008 | Configuration Tools | SQL Server Configuration Manager
  2. Click on “SQL Server Services”
  3. Right Click and Stop all your services

Open two Command Consoles – I ran both as Administrator

Window 1:

  1. Change path to location of your SQL Installation
  2. Typically: C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLBinn
  3. Run the following command: sqlservr.exe –m

  1. Command window will show log of SQL Starting and Running…

Window 2

  • Switch over to your second Command Window
  • Start the following Program: sqlcmd
  • Type the following if creating a Windows Account:
    • CREATE LOGIN [DomainUser] FROM WINDOWS;
  • Otherwise if using a SQL Account type the following:
    • CREATE LOGIN [LoginName] WITH PASSWORD = ‘SomePassword’;

  • Type the following:
    • EXE sp_addsrvrolemember ‘LoginName’, ‘sysadmin’

After this I actually had to reboot before SQL would let me log in using my new Domain Account. Or as my screenshots show, my new “SQL Security” account.

Welcome to my Blog…

Welcome to my blog!

I have been putting this off for a very long time now, mainly because really I don’t like to write much.  But I seem to always be going back and trying to find out what I was previously thinking, or eventually how I figured something out.  So here we are…

Hopefully these posts will jot my memory, and hopefully be useful for others out there.

My day-to-day job is mainly of being a BizTalker, that is working with Microsoft BizTalk Server.  I have been working with BizTalk Server now for over 10 years originally starting with the BizTalk Jumpstart Kit back in 2000.  We have sure come a long way since then…  So i’ll have some posts about BizTalk…

I used to teach .NET Programming for almost 4 years so when trying to describe concepts I try to bring it down to an easy level, hopefully I will be able to do the same with these Blog entries.  So i’ll have some posts about .NET concepts…

My Kids convinced me at the start of 2010 to buy an iMac, I was quite hesitant at the time because I have always been a Microsoft guy.  And to tell you the truth I love it!  Since then I have been trying to get stuff done on it.  Macs are suppose to be easy to use, and apparently they are, if you haven’t been in IT for a long time and set in your ways on how to do something.  So i’ll have some posts about using iMacs…

Since also getting this iMac I’ve gotten interested in iPhone/iPad Development, tried the Object C route, didn’t like it.  So I have gone with my .NET experience and using MonoTouch.  So i’ll have some posts about MonoTouch.

So expect to find a bit of everything on this blog so I hope you enjoy.

PS: I don’t know why I like “…” so much, but you’ll see it lots…