SQL Server add sysadmin role

From WickyWiki
Revision as of 15:17, 20 March 2019 by Wilbert (talk | contribs) (Created page with "Category:Windows Category:Windows SQL Server Category:201903 SQL Server add sysadmin role <! Administrator Permissions Denied --> Source: * https://serverfault....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


SQL Server add sysadmin role

<! Administrator Permissions Denied -->

Source:

Shut down SQL Server from services

net stop MSSQL$SQLEXPRESS

Open cmd-window (as admin) and run single-user mode as local admin with this command

"C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\Binn\sqlservr.exe" -m -s SQLEXPRESS

Other cmd-window (as admin):

sqlcmd -S .\SQLEXPRESS

Add your user to the 'sysadmin' group:

 sp_addsrvrolemember 'DOMAIN\user1', 'sysadmin'
 GO
 quit

Ctrl+C the single-user mode from the first cmd window to kill SQL Server.

Start services:

net start MSSQL$SQLEXPRESS

Log into Management Studio and the user you created should be listed under logins with the credential of "sysadmin."