db_name

Description

Returns the name of the database where the ID number is specified.

Syntax

db_name([database_id])

Parameters

database_id

is a numeric expression for the database ID (stored in sysdatabases.dbid).

Examples

Example 1

Returns the name of the current database:

select db_name()

Example 2

Returns the name of database ID 4:

select db_name(4)

------------------------------ 
sybsystemprocs

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute db_name.

See also

Functions col_name, db_id, object_name