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
For others who are looking for a query to return the GUID of a database:
SELECT d.name, drs.database_guid, d.group_database_id
FROM sys.databases d
JOIN sys.database_recovery_status drs
ON d.database_id = drs.database_id
It returns the database name, database GUID and GUID of this database in availability group. If database is not in AG, the last value returns null. This works in SQL Server 2016.