finding out instance name using reg query

  • Hi All,

    can any one help how to find out the instance name of the server by using reg query?

    Help appreciable!!

    Thanks.

  • SELECT ServerName = @@servername,

    InstanceName = CASE WHEN CharIndex('\', @@ServerName) = 0 THEN NULL

    ELSE SubString(@@ServerName, CharIndex('\', @@ServerName)+1, 100) END;

    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

  • if by reg you mean Registery

    Exec xp_regenumvalues N'HKEY_LOCAL_MACHINE',

    N'SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL';

  • I am fundamentally opposed to going to the registry unless it is ABSOLUTELY necessary.. And in this case it isn't..

    SELECT InstanceName = SERVERPROPERTY('InstanceName')

    It will return NULL for a default instance..

    CEWII

Viewing 4 posts - 1 through 3 (of 3 total)

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