select 'RoleName' = name, 'RoleId' = uid, 'IsAppRole' = isapprole
from sysusers where (issqlrole = 1 or isapprole = 1) and uid = gid

解决方案 »

  1.   

    To  zarge(鲨至),谢谢你的指点。我想问一下 uid = gid 条件起的是什么作用,它怎么把用户自定义的角色过滤出来的。再次谢谢。
      

  2.   

    sql 联机丛书sysusers
    数据库中每个 Microsoft® Windows 用户、Windows 组、Microsoft SQL Server™ 用户或 SQL Server 角色在表中占一行。列名 数据类型 描述 
    uid smallint 用户 ID,在此数据库中是唯一的。1 是数据库所有者。 
    status smallint 仅限内部使用。 
    ...
    gid smallint 此用户所属的组 ID。如果 uid = gid,那么此条目就定义一个组。 
    ...