MS SQL Tips & Tricks

How to determine file names used by current database

Information about database's files are stored in master database and table sysaltfiles. To determine which database is current one we need to use db_name(). So we have:

SELECT db_name(dbid), *
FROM master.dbo.sysaltfiles
where db_name(dbid)=db_name()
ORDER BY size DESC

Learn more tricks

Add Comment

Comments