INFORMATICS

The Best

Przełącznik języka

Zaproś mnie na KAWE

Jeżeli podoba Ci się strona i chcesz wspomóc projekt!

Postaw mi kawę na buycoffee.to

This Site

Płatnik

CMS

Hardware

Uncategorised

Emulators

Powershell

Storage Array

DNS

Antivirus program

Licznik

2.png8.png9.png6.png5.png9.png5.png
Today522
Yesterday681
This week3851
This month16720
Total2896595

Visitor Info

  • IP: 3.144.243.184
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

11
Online

czwartek, 25 kwiecień 2024 13:43

How to View SQL Server Database Size and File Locations

Gwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywna
 

How to View SQL Server Database Size and File Locations

 

SELECT
--database ID
mdf.database_id,
--database name
mdf.name,
--database file location
mdf.physical_name as data_file,
ldf.physical_name as log_file,
db_size_MB = CAST((mdf.size * 8.0)/1024 AS DECIMAL(8,2)),
log_size = CAST((ldf.size * 8.0 / 1024) AS DECIMAL(8,2))

FROM (SELECT * FROM sys.master_files WHERE type_desc = 'ROWS' ) mdf

JOIN (SELECT * FROM sys.master_files WHERE type_desc = 'LOG' ) ldf

ON mdf.database_id = ldf.database_id
--sort  DESC or ASC
order by db_size_MB DESC

Search