Wednesday, September 4, 2013

SQL Server Express: Batch file to give user sysadmin rights

sysadmin.bat

@echo off

set service=MSSQL$SQLEXPRESS

net stop %service%
net start %service% /mSQLCMD

sqlcmd -S (local)\sqlexpress -Q "EXEC master..sp_addsrvrolemember @loginame = N'DOMAIN\username', @rolename =N'sysadmin'"

net stop %service%
net start %service%

No comments:

Post a Comment