Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:55:40+00:00 2026-06-05T04:55:40+00:00

Is there a way to obtain a unique database identifier (such as a GUID)

  • 0

Is there a way to obtain a unique database identifier (such as a GUID) from a SQL 2005 database?

I found this article: http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.database.databaseguid%28v=sql.90%29.aspx

However, I need to be able to obtain the DatabaseGuid from T-SQL instead of VB.

EDIT: I am trying to uniquely determine the database for which I am connected. Through code I manually sync records between SQL Compact and SQL Server. Right now my users are in a test environment and when they are pointed to production SQL in the future I will need to re-sync entire tables instead of relying on rowversion. The rowversions will be different on the production server and if I am able to detect a database GUID change, I can re-sync the entire table.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:55:42+00:00Added an answer on June 5, 2026 at 4:55 am

    Whatever means SMO uses to get the database guid, you should be able to do the same. If you have problems figuring out what is SMO doing, you can use profiler to monitor what t executes and figure it out.

    In this case probably SMO reads the database_guid value from sys.database_recovery_status:

    Used to relate all the database files of a database together. All
    files must have this GUID in their header page for the database to
    start as expected. Only one database should ever have this GUID, but
    duplicates can be created by copying and attaching databases. RESTORE
    always generates a new GUID when you restore a database that does not
    yet exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Getting a FILE* from a std::fstream Is there a way to obtain
Is there any way to obtain this effect in a PHP version prior to
Is there a way to obtain the time zone from the callbacks received void
<script src=myscript.js?someParameter=123></script> From within myscript.js , is there any way to obtain that someParameter
Is there a way to obtain a relative rotation from core motion? What I
In extension to this question is there a way to obtain the effective URL
Is there any fast way to obtain unique elements in numpy? I have code
is there any way to obtain the table prefix after connect to the database
Is there any way to obtain an hexadecimal dump of a string in SQL
Is there a way to obtain something like a dictionary of all key-value pairs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.