1. User별 Procedure 권한 조회
SELECT OWN.NAME AS GRANTOR_NAME
, USR.NAME AS GRANTEE_NAME
, PRM.PERMISSION_NAME
, SCHEMA_NAME(PRC.SCHEMA_ID) AS OWNER
, PRC.NAME
FROM SYS.DATABASE_PERMISSIONS PRM
JOIN SYS.PROCEDURES PRC ON PRC.OBJECT_ID = PRM.MAJOR_ID
JOIN SYS.DATABASE_PRINCIPALS OWN ON OWN.PRINCIPAL_ID = PRM.GRANTOR_PRINCIPAL_ID
JOIN SYS.DATABASE_PRINCIPALS USR ON USR.PRINCIPAL_ID = PRM.GRANTEE_PRINCIPAL_ID
WHERE PRC.IS_MS_SHIPPED = 0
2. Role과 Member 조회
SELECT ROLE_PRINCIPAL_ID
, MEMBER_PRINCIPAL_ID
, R.NAME
, M.NAME
FROM SYS.DATABASE_ROLE_MEMBERS RM
JOIN SYS.DATABASE_PRINCIPALS R ON R.PRINCIPAL_ID = RM.ROLE_PRINCIPAL_ID
JOIN SYS.DATABASE_PRINCIPALS M ON M.PRINCIPAL_ID = RM.MEMBER_PRINCIPAL_ID
3. 사용자 정의 Procedure목록 조회
SELECT NAME
, OBJECT_ID
, SCHEMA_NAME(SCHEMA_ID)
FROM SYS.PROCEDURES
WHERE IS_MS_SHIPPED = 0