Skip to main content
ITServerSQL Server 2008

Script to add the current user to the SQL Server ‘sysadmin’ role

By 8th May 2014November 9th, 2017No Comments

This command script allows you to easily add yourself to the sysadmin role of a local SQL Server instance. You must be a member of the Windows local Administrators group, or have access to the credentials of a user who is. The script supports SQL Server 2005 and later.

The script is most useful if you are a developer trying to use SQL Server 2008 Express that was installed by someone else. In this situation you usually won’t have admin rights to the SQL Server 2008 Express instance, since by default only the person installing SQL Server 2008 is granted administrative privileges. 

The user who installed SQL Server 2008 Express can use SQL Server Management Studio to grant the necessary privileges to you. But what if SQL Server Management Studio was not installed? Or worse if the installing user is not available anymore?

This script fixes the problem in just a few clicks!

Just download this script  from the Microsoft MSDN Archives and run it. It will ask you for the SQL Server instance name (don’t worry if you don’t know your instance name: if it was not changed, the default of SQLEXPRESS will work for you).

If you are using Windows Vista or Windows Server 2008, or later, you may need to respond to these dialogs:

  • Click ‘Run’ to allow the command script to run after download.
  • Click ‘Open’ to allow the JScript script file to run.
  • If requested, provide the credentials of a member of the Windows local Administrators group. Then click ‘Yes’ to allow the command script to modify your computer.


If you are running Windows XP or Windows Server 2003, you may need to respond to these dialogs:

  • Click ‘Run’ to allow the command script to run after download.
  • Uncheck ‘Run this program with restricted access’, or provide credentials of a member of the Windows local Administrators group. Then click ‘OK’ to continue the command script.
Close Menu

Categories