how to get sql server instance guid

Posted on 2012-08-29
Last Modified: 2012-08-31
From what I understand each sql server instance is assigned a unique guid. Whats the t-sql statement to get that guid?
Question by:glenn_r
    LVL 16

    Expert Comment

    You could use the file_guid property for the first physical file in the database:

    select top 1 [file_guid] from [sys].[database_files]

    (although taking a physical backup would duplicate it)

    To uniquely identify the instance, combine the full instance name (server and sql server) along with the above - again, it may nt be 101% unique, but "close enough for government work", as you Americans say! :)



    Author Comment

    When I query that value its 'NULL'. Any ideas why?

    We're in Canada, 'North America' you could say. US is just a stones throw south 1 hour. "I reckon we aim fer 80% round deez parts!"
    LVL 16

    Accepted Solution

    It's possible that your db file doesn't have a GUID
    Try looking at
    select   *  from [sys].[database_files]
    and you should find files with GUIDs - it's a different pair for each DB.
    BTW, the master and model databases don't have GUIDs for their files.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now