Find an user in the entire SQL Server Instance

  • Hi All,

    If I need to find out an user account present anywehere in the SQL instances (say, login, jobs, repl agents, db owners, AlwaysOn groups), how to find and remove it?

    Thanks

    Thanks.

  • SQL-DBA-01 (9/13/2016)


    Hi All,

    If I need to find out an user account present anywehere in the SQL instances (say, login, jobs, repl agents, db owners, AlwaysOn groups), how to find and remove it?

    Thanks

    Quick suggestion

    😎

  • So you are suggesting to extract all the login accounts in the SQL Instance and there if the name matches or present can shed that off?

    Thanks.

  • SQL-DBA-01 (9/13/2016)


    So you are suggesting to extract all the login accounts in the SQL Instance and there if the name matches or present can shed that off?

    That is normally the simplest way;-)

    😎

  • lets say at replication the user can have exclusive rights or at alwayson group level oreven at the database level.

    Do you suggest running any other scripts to gather a more accurate report?

    Thanks.

  • For each database check sys.database_principals.

    For each login check sys.server_principals.

    For each job check suser_sname(owner_sid) from sysjobs.

    For each database check suser_sname(owner_sit) from sys.databases.

    All things have owners, you just need to go through the system tables.



    Shamless self promotion - read my blog http://sirsql.net

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

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