返回數(shù)據(jù)庫名。
DB_NAME ( database_id )
database_id
是應(yīng)返回數(shù)據(jù)庫的標(biāo)識號 (ID)。database_id 是 smallint,沒有默認(rèn)值。如果沒有指定 ID,則返回當(dāng)前數(shù)據(jù)庫名。
nvarchar(128)
此示例檢查 sysdatabases 中的每個數(shù)據(jù)庫,使用數(shù)據(jù)庫標(biāo)識號來確定數(shù)據(jù)庫名。
USE master
SELECT dbid, DB_NAME(dbid) AS DB_NAME
FROM sysdatabases
ORDER BY dbid
GO
下面是結(jié)果集:
dbid DB_NAME
------ ------------------------------
1 master
2 tempdb
3 model
4 msdb
5 pubs
(5 row(s) affected)
相關(guān)文章