SELECT
DB_NAME(database_id) [DatabaseName],
[name] AS [LogicalName],
(size*8)/1024 [MB]
FROM
sys.master_files
Results:
DatabaseName LogicalName MB
AdventureWorks AdventureWorks_Data 186
AdventureWorks AdventureWorks_Log 25
master master 50
master mastlog 10
tempdb tempdev 1024
tempdb templog 256
model modeldev 10
model modellog 2
msdb MSDBData 150
msdb MSDBLog 25
Throw this WHERE clause in there, if you'd like to exclude the system databases from your result-set:
WHERE
database_id > 4
This statement just provides a little more detail for the database you are connected to:
-- Individual File Size query
SELECT
name AS [FileName],
file_id [FileID],
physical_name AS [PhysName],
size/128 AS [TotalMB],
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 [AvailMB]
FROM
sys.database_files;
FileName FileID PhysName TotalMB AvailMB
MDW_primary 1 C:\MSSQL\Data\MDW_primary.mdf 10 8.750000
MDW_log 2 C:\MSSQL\Log\MDW_log.ldf 10 9.656250
MDW_data 3 C:\MSSQL\Data\MDW_data.ndf 200 198.562500
No comments:
Post a Comment