2

How can I find the definitions of below system functions in SQL Server:

  1. has_access
  2. permission_name

I tried with DAC connection but getting below error:

Msg 15009, Level 16, State 1, Procedure sp_helptext, Line 54 [Batch Start Line 118]
The object 'has_access' does not exist in database 'master' or is invalid for this operation.

Please let me know if any further details are required. Thanks!

Solomon Rutzky
  • 70,048
  • 8
  • 160
  • 306
SQLPRODDBA
  • 1,928
  • 2
  • 33
  • 48

1 Answers1

1

These two functions appear to be internal / built-in functions given that:

  1. they are referenced without a schema-name
  2. SSMS color-codes them the same as all other built-in functions

sys.server_permissions, on Line #7, has:

        p.type, permission_name(p.class, p.type) AS permission_name,

sys.server_principals, on Line # 18, has:

    WHERE has_access('LG', p.id) = 1

When the instance is in single-user mode, I can execute the following:

USE [mssqlsystemresource];
SELECT PERMISSION_NAME(100, 'COSQ');
-- CONNECT SQL

The same statement does not work outside of mssqlsystemresource, nor does it work in that DB when prefixed with sys. or dbo..

Ergo, no, there is no definition that you will be able to get.

Solomon Rutzky
  • 70,048
  • 8
  • 160
  • 306