A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: System Functions

db_name()

The System Function db_name() returns the database name of a database. The function db_name() is a Transact-SQL extension. It can be executed by any User.

Syntax of the System Function db_name()

    db_name(database_id)
    

The parameter of the System Function db_name()

"database_id"
The parameter "database_id" is the identification number of a database, as stored in the column "dbid" of the system table sysdatabases. If the parameter "database_id" is not specified, the function db_id() returns the identification number of the database currently in use.

Example for the System Function db_name()

    select db_name("2")
go
-----
tempdb

Returns the database name "tempdb". The database "tempdb" always has a "dbid" of 2.

See also:

ASE T-SQL - Aggregate Functions,
audit_event_name(),
col_length(),
col_name(),
curunreservedpgs(),
datachange(),
datalength(),
data_pages(),
data_pgs(),
db_id(),
host_id(),
host_name(),
identity(),
index_col(),
index_colorder(),
isnull(),
lct_admin(),
license_enabled(),
lockscheme(),
next_identity(),
object_id(),
object_name(),
pagesize(),
pointer_size(),
ptn_data_pgs(),
reserved_pages(),
reserved_pgs(),
rowcnt(),
row_count(),
showplan_in_xml(),
syb_sendmsg(),
syb_sendmsg(),
System Functions,
tempdb_id(),
tran_dumpable_status(),
tsequal(),
used_pages(),
used_pgs().