DB_ID

Returns the database identification (ID) number.

Syntax

DB_ID ( [ 'database_name' ] )

Arguments

database_name

Is the database name used to return the corresponding database ID. database_name is sysname. If database_name is omitted, the current database ID is returned.

Return types

int

Examples

SELECT DB_ID() AS [Database ID];

See Also