Query to find the service account through which SQL Server is running?

  • Hello Experts

    Without going to services.msc / configuration manager, is there anyway to know the service account through which SQL server is running?

    Thanks.

  • IS this a good query to check or do you suggest any other probable best way to find the details? Please suggest

    select net_library,loginame,hostname,spid from sysprocesses

    where spid > 50 and net_library = 'LPC'

    Thanks.

  • DECLARE @SN NVARCHAR(128);

    EXEC master.dbo.xp_regread

    'HKEY_LOCAL_MACHINE',

    'SYSTEM\CurrentControlSet\services\MSSQLServer',

    'ObjectName',

    @SN OUTPUT;

    SELECT @SN;

  • Many thanks, Crystal. Good Day.

    Thanks.

  • SQL-DBA-01 (7/23/2015)


    Hello Experts

    Without going to services.msc / configuration manager, is there anyway to know the service account through which SQL server is running?

    Starting with SQL Server 2008R2, you can run this query:

    SELECT * FROM sys.dm_server_services;

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • To the Room, this is my final query now..

    --1.

    DECLARE @SN NVARCHAR(1000);

    EXEC master.dbo.xp_regread

    'HKEY_LOCAL_MACHINE',

    'SYSTEM\CurrentControlSet\services\MSSQLServer',

    'ObjectName',

    @SN OUTPUT;

    SELECT @SN;

    --2.

    declare @string VARCHAR(4000);

    SET @string = 'setspn -L "' + @SN + '"'

    select @string

    exec xp_cmdshell @string

    Thanks.

  • Thnx Wayne. Appreciate your response.

    Thanks.

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

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