Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize

DB_NAME

SQL Server 2000

Returns the database name.

Syntax

DB_NAME ( database_id )

Arguments

database_id

Is the identification number (ID) of the database to be returned. database_id is smallint, with no default. If no ID is specified, the current database name is returned.

Return Types

nvarchar(128)

Examples

This example examines each database in sysdatabases using the database identification number to determine the database name.

USE master
SELECT dbid, DB_NAME(dbid) AS DB_NAME
FROM sysdatabases
ORDER BY dbid
GO

Here is the result set:

dbid   DB_NAME                        
------ ------------------------------ 
1      master                         
2      tempdb                         
3      model                          
4      msdb                           
5      pubs                           

(5 row(s) affected)

See Also

Metadata Functions

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft