To get the ID of the selected database refer the following syntax
Syntax:
DB_ID()
Example:
SELECT DB_ID()
Output:
5
Open a new query window ,select the required database and Now execute the above function,then you will get the ID of the selected database.