Check users in a security group in SQL Server

前端 未结 6 2064
情歌与酒
情歌与酒 2020-12-30 04:42

In the Security/Users folder in my database, I have a bunch of security groups, include \"MyApplication Users\". I need to check if I am (or another user is) in this group,

6条回答
  •  梦毁少年i
    2020-12-30 05:27

    Checking yourself or the current user:

    SELECT IS_MEMBER('[group or role]')
    

    A result of 1 = yes,0 = no, and null = the group or role queried is not valid.

    To get a list of the users, try xp_logininfo if extended procs are enabled and the group in question is a windows group :

    EXEC master..xp_logininfo 
    @acctname = '[group]',
    @option = 'members'
    

提交回复
热议问题