Search code examples
sql-serverdatabase-backups

Unique ID of the SQL Server Database


There are many SQL Server databases created from the same .BAK file. I need to get the unique ID-value of each one. Getting UID of the DBfiles returns everywhere the same value.

Different situation with Oracle. It has a unique ID of each DB service.

Please, let me know what trick or method would be used in my case? It should be just one SQL query.

Thanks.


Solution

  • This should do it:

    Select * from Sys.Databases
    

    In your case I think you need name, database_id and owner_sid columns, not sure if they're all relevant to your question.