Today I was working on a SQL Express database. The issue was domains were changed and nobody updated the permissions on the database prior to moving domains. When attempting to gain access to the database through SQL Management Studio I got error messages like

“the server principal is not able to access the database under the current security context”

Even attempting to change the sa account or alter in anyway I got message like the one below.

“cannot alter the login sa because it does not exist or you do not have permission”

The solution was to use PSExec and open management studio with the system account and then replace the permissions.

  • Download PSExec.exe and place into Windows\System 32
  • Open the command prompt as the administrator
  • Execute SSMS from the command prompt on the machine hosting the SQL database using the following command
    • PsExec -s -i "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
    • Note that the path to SSMS may be different depending on the configuration of your system
  • There are a few other caveats listed in the original article linked above
    • UAC may need to be disabled (worked Ok for me still enabled)
    • Your account needs to be a local admin for this work
    • May or may not work remotely


BIG Thanks to Shrout1