I got a new machine with SQL Express installed. However, it only had SA user. I didn’t know the SA password and my windows user was not the admin either, so I could not connect to the database instance.

Here is how I added my windows user to be Sysadmin.

  • Stop the SQLExpress windows service.
  • Start the SQLExpress with -m in Start parameters.
  • Open the Command Prompt as Administrator mode and run following commands
    • 0sql -S .\SQLExpress -E
      • ‘.’ represent the localhost in above line. Replace ‘.’ with server name as┬áneeded.
    • create login [Domain\User] from windows
    • go
    • exec sp_addsrvrolemember ‘Domain\User’, ‘Sysadmin’
    • go
    • quit
  • Stop the SQLExpress
  • Start the SQLExpress without -m in Start parameter

That’s it.

Happy Logging..

Adding Windows user to Sysadmin Role in SQLExpress without SA priviledge.
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *