Tuesday, 29 March 2016

How to get the database ID in SQL Server ?

In a Single SQL Server Instance ,it is possible to have multiple databases.
Each database has its own unique ID.

To get the ID of the database refer the following syntax 

Syntax:

DB_ID('Database Name')

Example:

SELECT DB_ID('Sample')

Output:

5

Now the ID of the Sample database is 5.


No comments:

Post a Comment