Syntax of DB_ID Function :
DB_ID ( [ 'database_name' ] )
database_name is a database name. It is an optional parameter. It is of type nvarchar.
Return type of DB_ID function is smallint.
Examples of DB_ID Function :
Example 1 : Use of DB_ID function to get id of database in select clause
SELECT DB_ID('Northwind')
Output
10
Above example returns id for Northwind database.