求两个SQL语句。1. 查询当前数据库用户所属的所有角色 2. 某一个角色的所有权限。

解决方案 »

  1.   

    http://topic.csdn.net/u/20100312/10/7804248a-4172-4e97-a6a8-5902db500849.html?94025楼主,今天的精华帖
      

  2.   

    -- 查询当前数据库用户账户所属的数据库角色
    select user_name(groupuid) from sysmembers where memberuid=user_id()-- 查询当前数据库用户账户的权限
    select object_name(id) obj,
    (case [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' end) perm
    from sysprotects where [uid]=user_id()
      

  3.   


    这个似乎不对啊(0 row(s) affected)