Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way in SQL Server to uniquely identify a database?

Tags:

sql-server

Is there any way to uniquely identify a database?

If we were to copy a database to another machine, this instance is assumed to be different. I checked on master tables, but could not identify any information that can identify this.

like image 282
sraj Avatar asked Jun 02 '10 11:06

sraj


1 Answers

service_broker_guid in sys.databases comes pretty close to what you ask. It is a uniqueidentfier generated when the database is created and is preserved as the database is moved around (detach and attach, backup and restored, server rename etc). It can be explicitly changed with ALTER DATABASE ... SET NEW_BROKER;.

like image 184
Remus Rusanu Avatar answered Oct 04 '22 03:10

Remus Rusanu