Created
September 22, 2014 10:33
-
-
Save JohnLBevan/2582960a23605e0cecec to your computer and use it in GitHub Desktop.
Grant user sysadmin access to a SQL instance from the command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--::example batch file: | |
--pushd \\ukexchange\sysgrp\scripts\sql | |
--sqlcmd -S ccioaxpd05edc\axeam_train -i \\ukexchange\sysgrp\scripts\sql\grantsysadmin.sql -E -o \\ukexchange\sysgrp\scripts\sql\GrantSysAdmin.rpt | |
--popd | |
--sql file: | |
-- - usage: | |
-- sqlcmd -S <server\instance> -i \\ukexchange\sysgrp\scripts\sql\grantsysadmin.sql -E -o \\ukexchange\sysgrp\scripts\sql\GrantSysAdmin.rpt | |
use master | |
go | |
--give sys admin to the CCIT DBA team | |
EXEC master..sp_addsrvrolemember @loginame = N'eu\svc-dataway1', @rolename = N'sysadmin' | |
go | |
--give sys admin to myself (so I can check the script's worked & validate svc's access) | |
EXEC master..sp_addsrvrolemember @loginame = N'eu\sejb', @rolename = N'sysadmin' | |
go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment