Returns column privilege information for a single table in the current environment.
sp_column_privileges is equivalent to SQLColumnPrivileges in ODBC. The results returned are ordered by TABLE_QUALIFIER, TABLE_OWNER, TABLE_NAME, COLUMN_NAME, and PRIVILEGE.
Table qualifier name. This field can be NULL.
Table owner name. This field always returns a value.
Table name. This field always returns a value.
Column name, for each column of the TABLE_NAME returned. This field always returns a value.
Database user name that has granted permissions on this COLUMN_NAME to the listed GRANTEE. In SQL Server, this column is always the same as the TABLE_OWNER. This field always returns a value.
The GRANTOR column can be either the database owner (TABLE_OWNER) or a user to whom the database owner granted permissions by using the WITH GRANT OPTION clause in the GRANT statement.
Database user name that has been granted permissions on this COLUMN_NAME by the listed GRANTOR. In SQL Server, this column always includes a database user from the sysusers table. This field always returns a value.
One of the available column permissions. Column permissions can be one of the following values (or other values supported by the data source when implementation is defined):
SELECT = GRANTEE can retrieve data for the columns.
INSERT = GRANTEE can provide data for this column when new rows are inserted (by the GRANTEE) into the table.
UPDATE = GRANTEE can modify existing data in the column.
REFERENCES = GRANTEE can reference a column in a foreign table in a primary key/foreign key relationship. Primary key/foreign key relationships are defined by using table constraints.
Indicates whether the GRANTEE is permitted to grant permissions to other users (often referred to as "grant with grant" permission). Can be YES, NO, or NULL. An unknown, or NULL, value refers to a data source for which "grant with grant" is not applicable.
The following example returns column privilege information for a specific column.
USE AdventureWorks; GO EXEC sp_column_privileges @table_name = 'Employee' ,@table_owner = 'HumanResources' ,@@table_qualifier = 'AdventureWorks' ,@@column_name = 'SalariedFlag';