Returns the ID number of the specified database.
db_id(database_name)
is the name of a database. database_name must be a character expression. If it is a constant expression, it must be enclosed in quotes.
select db_id("sybsystemprocs")
------ 4
db_id, a system function, returns the database ID number.
If you do not specify a database_name, db_id returns the ID number of the current database.
For general information about system functions, see “System functions”.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute db_id.