Skip to content

Instantly share code, notes, and snippets.

@gscattolin
Created September 10, 2013 18:28
Show Gist options
  • Select an option

  • Save gscattolin/6513495 to your computer and use it in GitHub Desktop.

Select an option

Save gscattolin/6513495 to your computer and use it in GitHub Desktop.
Access to SQL and add admin rights
shut down SQL Server from services
open cmd window (as admin) and run single-user mode as local admin with this command
c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -m -s SQLEXPRESS
open another cmd window (as admin)
open sqlcmd
sqlcmd -S .\SQLEXPRESS
Now add the sysadmin user:
sp_addsrvrolemember 'domain\user', 'sysadmin'
GO
Ctrl+C the single-user mode from the first cmd window to kill SQL Server.
Restart it from services the normal way.
Log into Management Studio and the user you created should be listed under logins with the credential of "sysadmin."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment