Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_table_privileges_ex

  No additional text.


Syntax

create procedure sys.sp_table_privileges_ex
(
    @table_server       sysname,
    @table_name         sysname = null,
    @table_schema       sysname = null,
    @table_catalog      sysname = null,
    @fUsePattern        bit = 1 -- To allow users to explicitly disable all pattern matching.
)
as
    if (@fUsePattern = 1) -- Does the user want it?
    begin
        if ((isnull(charindex('%', @table_name),0) = 0) and
            (isnull(charindex('_', @table_name),0) = 0) and
            (isnull(charindex('[', @table_name),0) = 0) and
            (isnull(charindex('%', @table_schema),0) = 0) and
            (isnull(charindex('_', @table_schema),0) = 0) and
            (isnull(charindex('[', @table_schema),0) = 0))
        begin
            select @fUsePattern = 0 -- not a single wild char, so go the fast way.
        end
    end

    if @fUsePattern = 0
    begin
        /* -- Debug output, do not remove it.
        print '*************'
        print 'No pattern matching.'
        print @fUsePattern
        print isnull(@table_name, '@table_name = null')
        print isnull(@table_schema, '@table_schema = null')
        print '*************'
        */
        select
            TABLE_CAT       = rtp.TABLE_CATALOG,
            TABLE_SCHEM     = rtp.TABLE_SCHEMA,
            TABLE_NAME      = rtp.TABLE_NAME,
            GRANTOR         = rtp.GRANTOR,
            GRANTEE         = rtp.GRANTEE,
            PRIVILEGE       = rtp.PRIVILEGE_TYPE,
            IS_GRANTABLE    = case rtp.IS_GRANTABLE
                                when 1 then 'YES'
                                when 0 then 'NO'
                                else null
                              end
        from
            sys.fn_remote_table_privileges (@table_server,
                                            @table_catalog,
                                            @table_schema,
                                            @table_name,
                                            NULL,
                                            NULL) rtp
        order by 1, 2, 3, 6
    end
    else
    begin
        /* -- Debug output, do not remove it.
        print '*************'
        print 'THERE IS pattern matching!'
        print @fUsePattern
        print isnull(@table_name, '@table_name = null')
        print isnull(@table_schema, '@table_schema = null')
        print '*************'
        */
        select
            TABLE_CAT       = rtp.TABLE_CATALOG,
            TABLE_SCHEM     = rtp.TABLE_SCHEMA,
            TABLE_NAME      = rtp.TABLE_NAME,
            GRANTOR         = rtp.GRANTOR,
            GRANTEE         = rtp.GRANTEE,
            PRIVILEGE       = rtp.PRIVILEGE_TYPE,
            IS_GRANTABLE    = case rtp.IS_GRANTABLE
                                when 1 then 'YES'
                                when 0 then 'NO'
                                else null
                              end
        from
            sys.fn_remote_table_privileges (@table_server,
                                            @table_catalog,
                                            NULL,
                                            NULL,
                                            NULL,
                                            NULL) rtp
        where
            (TABLE_SCHEMA like @table_schema or
             @table_schema is NULL or
             (TABLE_SCHEMA is NULL and @table_schema = N'%')) and
            (TABLE_NAME like @table_name or @table_name is NULL)
        order by 1, 2, 3, 6
    end

 
Last revision 2008RTM
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