Share

Query to check size of Databases in SQL Server

Open SSMS ( SQL SERVER MANAGEMENT STUDIO ) ==> Right click on the instance ==> New Query and paste the below code to find the Auto Shrink status


Total db's in GB :

SELECT CONVERT(DECIMAL(10,2),(SUM(size * 8.00) / 1024.00 / 1024.00)) As UsedSpace
FROM master.sys.master_files





All DB's individually :

with fs
as
(
    select database_id, type, size * 8.0 / 1024 size
    from sys.master_files
)
select
    name,
    (select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB,
    (select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB
from sys.databases db

Share

Fixing a database with a high VLF count

Fixing a database with a high VLF count is a simple process: 1. Check the current size of the transaction log. 2. Backup the transacti...