Need to run the Statement to attain the list of users in SQL 2008

  • Hello,

    I would really appreciate if I can get the easy way to pull the list of all the sql and AD accounts in SQL (at database level, I need to run this for my audit purposes,

    Thanks in Advance,

    Dev

  • Were you just looking for something simple like this?

    use [DatabaseName]

    Go

    select name from sysusers

    where islogin = 1

  • you may want to try posting in the correct forum in future 😉

    The database table you need to query is sys.database_principals, this script should help!

    use yourdb

    select 'Login name : ' + name +

    ', SID : ' + sys.fn_varbintohexstr(sid) +

    ', Type : ' + type_desc +

    ', Default Schema : ' + default_schema_name +

    ', Created Date : ' + cast(create_date as varchar(20)) +

    ', Modified : ' + cast(modify_date as varchar(20))

    from sys.database_principals

    --anything not a database role or default account (e.g. sys, dbo, etc)

    where is_fixed_role <> 1 and principal_id > 4

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Hello,

    I need a statement which I could run once and it would genertate the information for all the users existing in SQL with the type of permissions,

    Much Appreciated,

    Thanks,

    Dev

  • Hello,

    I need a statement which I could run once and it would genertate the information for all the users existing in SQL with the type of permissions,

    Much Appreciated,

    Thanks,

    Dev

  • dsohal (4/27/2012)


    Hello,

    I need a statement which I could run once and it would genertate the information for all the users existing in SQL with the type of permissions,

    Much Appreciated,

    Thanks,

    Dev

    First of all, it’s nice to see another ‘Dev’ in SSC.

    Second, why did you come back to old thread after a year? Shouldn’t it be a new thread?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply