Search Wiki:

Get admin rights to your local SQL Server Express with this simple script


Description


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!

SQL Server Restart Warning

This script will restart the specified SQL Server instance (by default, SQLEXPRESS). All active connections to this instance will be lost. For this reason, it should not be used against production servers.

Usage

Just download the script 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.
Last edited Feb 23 2010 at 8:46 AM  by wardbeattie, version 24
Comments
dasari_ramacharan wrote  Aug 5 2010 at 2:44 PM  
thanks it works good.can we know the source code for it?

GiddyUpHorsey wrote  May 24 2011 at 3:39 AM  
One day I was trying to use SQL Profiler and it wouldn't work anymore, although it worked fine the last time I used it some months earlier. Running this script fixed the problem.

Astatke wrote  Aug 2 2011 at 7:36 PM  
Thank you for this important script.
It saved me from the verge of reinsstalling SQL server. If yu want to install SQL reporting services in a SharePoint Integrated mode, you need to have the sysadmin role. In my case I didn't have the sysadmon role but thanks to this script I was able to do it in one minute.

Martin_Martin wrote  Oct 31 2011 at 9:44 AM  
This script is very good, thank you for you share.

Roopesh wrote  Mar 8 at 8:58 PM  
The script works perfectly. Great work who ever has done it.

Updating...
Page view tracker