Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.spt_column_privileges_owner_view

  No additional text.


Syntax

create view sys.spt_column_privileges_owner_view
as
    select -- Add rows for table owner
    -- begin (for doing joins)
        OBJECT_ID       = o.object_id,
        SCHEMA_ID       = o.schema_id,
    -- end (for doing joins)
        GRANTOR         = convert(sysname, N'dbo'),
        GRANTEE         = user_name(ObjectProperty(o.object_id,'ownerid')),
        TABLE_CATALOG   = db_name(),
        TABLE_SCHEMA    = schema_name(o.schema_id),
        TABLE_NAME      = o.name,
        COLUMN_NAME     = c.name,
        COLUMN_GUID     = convert(uniqueidentifier,null),
        COLUMN_PROPID   = convert(int,null),
        PRIVILEGE_TYPE  = convert(nvarchar(30),
                                    case v.number
                                    when 193 then N'SELECT'
                                    when 195 then N'INSERT'
                                    when 197 then N'UPDATE'
                                    when 26  then N'REFERENCES'
                                    end),
        IS_GRANTABLE    = convert(bit,1)
    from
        sys.all_columns c inner join
        sys.all_objects o on
            (
                o.object_id = c.object_id and
                o.type in ('S','U','V')  -- limit columns to tables and views only
            ) inner join
        master.dbo.spt_values v on
            (
                v.type = 'P' and -- gets all exposed privileges and tries to find revoked ones (see below)
                v.number in (193,195,197,26) -- SELECT/INSERT/UPDATE/REFERENCES
            )
    where
        not exists ( -- exclude revoke'd privileges
                    select
                        major_id
                    from
                        sys.database_permissions p1
                    where
                        p1.major_id = o.object_id and
                        p1.grantee_principal_id = o.schema_id and
                        p1.state = 'D' and
                        p1.type = case v.number
                                      when 193 then 'SL'
                                      when 195 then 'IN'
                                      when 197 then 'UP'
                                      when 26  then 'RF'
                                      end
                   )

 
Last revision 2008RTM
See also

  sp_column_privileges_rowset (Procedure)
sp_column_privileges_rowset2 (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash