SQL Server 2005 account running SQL Server services

  • Hi,

    I need to make a script that deletes all the users (windows users) from a SQL Server 2005 instance if they are not the users that are running the SQL Server Service or the SQL Server Agent Service or the browser service or any other SQL Server service.

    How can i see (by t-sql) wich are the user accounts that are running SQL Server 2005 services?

    Thank you

  • This is from SQL2000 (default instance) but should work in 2005 as well

    declare @account varchar(50)

    print 'MSSQLServer service account '

    exec xp_regread 'HKEY_LOCAL_MACHINE', 'SYSTEM\CurrentControlSet\Services\MSSQLServer', 'Objectname', @account output

    print @account

    print 'SQLServerAgent service account '

    exec xp_regread 'HKEY_LOCAL_MACHINE', 'SYSTEM\CurrentControlSet\Services\SQLServerAgent', 'Objectname', @account output

    print @account

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

  • thank you very much i will try that.

    What about the other services like SQL Server Browser and others?

  • thank you very much i will try that.

    What about the other services like SQL Server Browser and others?

  • same place, different entry?

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

  • ups.... lol thank you 🙂

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

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