DB_Name(DB_ID) will provide you the database name. The hierarchy is like system tables will have the initial values followed by user databases.
select DB_NAME(1) --- returns Master database
select DB_NAME(2)--- returns Tempdb database
select DB_NAME(3)--- returns Model database
select DB_NAME(4)--- returns MSDB database
select DB_NAME(5)--- returns User database1 etc..,
No comments:
Post a Comment