sql 权限语句

来源:互联网 发布:python socket 雪峰 编辑:程序博客网 时间:2024/06/07 10:05

select  object_name(a.id) as objectname,
   user_name(a.uid) as usename,
   case b.issqlrole when 1 then 'Group '
      else 'User'
   end as Role,
   case a.protecttype when 205 then 'Grant'
      when 204 then 'Grant'
      when 206 then 'Deny'
      else 'Revoke'
   end as ProtectType,
   case a.[action] when 26  then 'REFERENCES'
        when 178 then 'CREATE FUNCTION'
        when 193 then 'SELECT'
                      when 195 then 'INSERT'
                      when 196 then 'DELETE'
                      when 197 then 'UPDATE'
        when 198 then 'CREATE TABLE'
        when 203 then 'CREATE DATABASE'
        when 207 then 'CREATE VIEW'
                      when 222 then 'CREATE PROCEDURE'
               when 224 then 'EXECUTE'
                      when 228 then 'BACKUP DATABASE'
               when 233 then 'CREATE DEFAULT'
                      when 235 then 'BACKUP LOG'
                      when 236 then 'CREATE RULE'
                      else '0'
           end as [Action],
    user_name(a.grantor) as Grantor
  from sysprotects a inner join sysusers b on a.uid=b.uid
  where exists (select 1 from  sysobjects
         where [name]=object_name(a.id) and xtype <>'S' )
  and  a.uid=user_id('bpm')
  order by object_name(a.id)

 

原创粉丝点击