HAS_PERMS_BY_NAME()
Evaluates the effective permission of the current user on a securable. A related function is fn_my_permissions.
Signature
HAS_PERMS_BY_NAME ( securable , securable_class , permission
[ , sub-securable ] [ , sub-securable_class ] )Parameters
- securable — Is the name of the securable. If the securable is the server itself, this value should be set to NULL. *securable* is a scalar expression of type sysname. There is no default.
- securable_class — Is the name of the class of securable against which the permission is tested. *securable_class* is a scalar expression of type nvarchar(60).
- permission — A nonnull scalar expression of type sysname that represents the permission name to be checked. There is no default. The permission name ANY is a wildcard.
- sub-securable — An optional scalar expression of type sysname that represents the name of the securable sub-entity against which the permission is tested. The default is NULL.
- sub-securable_class — An optional scalar expression of type nvarchar(60) that represent the class of securable subentity against which the permission is tested. The default is NULL.
Examples
SELECT HAS_PERMS_BY_NAME(null, null, 'VIEW SERVER STATE');1SELECT HAS_PERMS_BY_NAME('Ps', 'LOGIN', 'IMPERSONATE');0SELECT HAS_PERMS_BY_NAME(db_name(), 'DATABASE', 'ANY');1Run against SQL Server 16.0.4265.3 on 2026-09-13. This is the output we got, not the documentation’s.
Signature and description adapted from the Microsoft SQL documentation, used under the CC BY 4.0. SQL Server and Azure are trademarks of the Microsoft group of companies. This page is not affiliated with Microsoft.