Wednesday, September 4, 2013

SQL Server Express: Batch file to check if current user is sysadmin

issysadmin.bat

@echo off

sqlcmd -S (local)\sqlexpress -Q ^
"if exists( select * from fn_my_permissions(NULL, 'SERVER') where permission_name = 'CONTROL SERVER') print 'You are a sysadmin.'"

No comments:

Post a Comment