How to Display SQL services account information using TSQL

  • Please help= I need to find out where do we use the service account besides to the specific services?

  • The service account details can be obtained by reading the registry. Here is an example.

    DECLARE @ServiceaccountName varchar(250)

    EXECUTE master.dbo.xp_instance_regread

    N'HKEY_LOCAL_MACHINE',

    N'SYSTEM\CurrentControlSet\Services\MSSQLSERVER',

    N'ObjectName',

    @ServiceAccountName OUTPUT,

    N'no_output'

    SELECT @ServiceaccountName

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • If you're looking for items outside of SQL Server entirely, that's not only a registry issue, but a possible Active Directory issue. There is no way for to use T-SQL to get all the information you're looking for.

    If you're looking for it inside other SQL Servers, that's a different kettle of fish. Try the sys.server_role_members and sys.server_principals tables on all your servers.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Thank you somuch guys, but I need to find out where do we use the 'service accounts' besides to the specific services? For example, if we use this service account on any job, package, or any other procedures etc.

  • The below query will give you the list of jobs owned by the Service Account.

    select a.name,b.name

    from msdb..sysjobs a, master..syslogins b

    where a.owner_sid=b.sid

    and b.name='YourServiceAccountName'

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • For dtsconfig files, you can do a Windows Explorer search on the directory and it should be able to search inside the files for the account name in question. Just don't forget your wildcards.

    Same with all the directories on the NAS / SAN you're using. Remember, the bigger the directory structure, the longer the search will take.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

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

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