db_name

Description

Displays the name of the database with the specified ID number.

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

Documentation Transact-SQL Users Guide

Functions col_name, db_id, object_name