April 17, 2012

sp_column_privileges_rowset2 (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_column_privileges_rowset2(nvarchar @table_schema
, nvarchar @column_name
, nvarchar @grantor
, nvarchar @grantee)

MetaData:

   
create procedure sys.sp_column_privileges_rowset2
(
@table_schema sysname = null,
@column_name sysname = null,
@grantor sysname = null,
@grantee sysname = null
)
as
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- copy & pasted from version 1 of the SProc and removed checks for 1st parameter !
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
select -- Rows for explicitly set database permissions.
GRANTOR = s_cpsv.GRANTOR,
GRANTEE = s_cpsv.GRANTEE,
TABLE_CATALOG = s_cpsv.TABLE_CATALOG,
TABLE_SCHEMA = s_cpsv.TABLE_SCHEMA,
TABLE_NAME = s_cpsv.TABLE_NAME,
COLUMN_NAME = s_cpsv.COLUMN_NAME,
COLUMN_GUID = s_cpsv.COLUMN_GUID,
COLUMN_PROPID = s_cpsv.COLUMN_PROPID,
PRIVILEGE_TYPE = s_cpsv.PRIVILEGE_TYPE,
IS_GRANTABLE = s_cpsv.IS_GRANTABLE
from
sys.spt_column_privileges_set_view s_cpsv
where
(@table_schema is null or schema_id(@table_schema) = s_cpsv.schema_id) and -- check schema
(@column_name is null or @column_name = s_cpsv.COLUMN_NAME) and
(@grantor is null or @grantor = s_cpsv.GRANTOR) and
(@grantee is null or @grantee = s_cpsv.GRANTEE)

union all

select -- Add rows for table owner
GRANTOR = s_cpov.GRANTOR,
GRANTEE = s_cpov.GRANTEE,
TABLE_CATALOG = s_cpov.TABLE_CATALOG,
TABLE_SCHEMA = s_cpov.TABLE_SCHEMA,
TABLE_NAME = s_cpov.TABLE_NAME,
COLUMN_NAME = s_cpov.COLUMN_NAME,
COLUMN_GUID = s_cpov.COLUMN_GUID,
COLUMN_PROPID = s_cpov.COLUMN_PROPID,
PRIVILEGE_TYPE = s_cpov.PRIVILEGE_TYPE,
IS_GRANTABLE = s_cpov.IS_GRANTABLE
from
sys.spt_column_privileges_owner_view s_cpov
where
(@table_schema is null or schema_id(@table_schema) = s_cpov.schema_id) and -- check schema
(@column_name is null or @column_name = s_cpov.COLUMN_NAME) and
(@grantor is null or @grantor = s_cpov.GRANTOR) and
(@grantee is null or @grantee = s_cpov.GRANTEE)

order by 4, 5, 6, 9, 1, 2

No comments:

Post a Comment

Total Pageviews