I am writing a tool that is used to perform several database operations.
But the tool should only be used with one specific database.
Now I'm looking for a way to safely identify the database to which the tool is connected.
At first, I thought about just checking the type string SERVERNAME\INSTANCE#Database.
I also found this question where the solution should use a GUID, but this GUID changes if the database is restored on another server.
The database should be recognized even if it is being moved to another server or instance or the database name is being changed.
Is there a reliable way to achieve this?
source
share