Get all SQL Server databases sizes in Bytes, MBs & GBs. Here in script f.size is the number of 8K pages in the database, so there are f.size * 8 * 1024 bytes in the database & the rest is pure conversion to mega/giga/ etc..
There are 1048576 bytes in a megabyte, 1073741824 bytes in a gigabyte.
Simply copy the below script & run it in SSMS
d.name as Database_Name,
f.name as Physical_File_Type,
f.physical_name as Physical_File_Location,
f.state_desc as Online_Status,
f.size * 8.00 * 1024.00 as Size_In_Bytes,
cast((f.size * 8.00 * 1024.00) / 1048576.00 as numeric (18,2)) as Size_In_MB,
cast((f.size * 8.00 * 1024.00) / 1073741824.00 as numeric(18,2)) as Size_In_GB,
cast(cast(v.total_bytes - v.available_bytes as float) / cast(v.total_bytes as float) * 100 as numeric(18,2)) Used_Disk_Percent
inner join sys.databases d on d.database_id = f.database_id
cross apply sys.dm_os_volume_stats(f.database_id, f.file_id) v
Here is the output
Recently we moved whole on-premises resources to the cloud. In an easy word, we have moved SQL Server from on-premises…
In SQL Server sp_send_dbmail use to send emails and the SQL Server log all the status of each message processed…