SQL Server add sysadmin role: Difference between revisions
From WickyWiki
Created page with "Category:Windows Category:Windows SQL Server Category:201903 SQL Server add sysadmin role <! Administrator Permissions Denied --> Source: * https://serverfault...." |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
[[Category:Windows SQL Server]] | [[Category:Windows SQL Server]] | ||
[[Category:201903]] | [[Category:201903]] | ||
<!-- Administrator Permissions Denied --> | |||
At some point I was no longer 'sysadmin' on my local SQL Server Express installation. The following was a solution. | |||
<! Administrator Permissions Denied --> | |||
Source: | Source: | ||
Latest revision as of 15:40, 20 March 2019
At some point I was no longer 'sysadmin' on my local SQL Server Express installation. The following was a solution.
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."