microsoft sql server: check users own permissions
You can check current user's right on certain securables using [sys.fn_mypermissions][1]
which returns all permission on the securable. You can also check a specific permission with HAS_PERMS_BY_NAME
. Eg. you can check for CONTROL SERVER
permission which implies an administrator is logged in:
SELECT HAS_PERMS_BY_NAME(null, null, 'CONTROL SERVER');