Wednesday, 11 August 2021

To find Database Size in GBs,TBs

 Use below T-Sql command to find the database size in GBs,TB's


--Database Sizes


select

'server' = @@servername,d.NAME

, 'total size in megabytes'= convert(decimal(10,2),(sum(size * 8.00) / 1024.00 ))

, 'total size in gigabytes' = convert(decimal(10,2),(sum(size * 8.00) / 1024.00 / 1024.00))

, 'total size in terabytes' = convert(decimal(10,2),(sum(size * 8.00) / 1024.00 / 1024.00 / 1024.00)) from

sys.master_files mf

INNER JOIN sys.databases d ON d.database_id = mf.database_id

WHERE d.database_id > 4

and d.is_read_only<>1

GROUP BY d.NAME

ORDER BY d.NAME

No comments:

Post a Comment

Disable CDC at table level

 How to Disable CDC( Change Data Capture) for tables Change Data Capture (cdc) property is disabled as default.  here I will Query you how t...