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/micr
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.