Shrinking SQL Server Db_log file size — SQL Server DB Maintenance

Below is a script which reduces the size of DB_log.ldf file in SQL Server

Some times SQL DB_log.ldf takes up more server space in GBs to shrink and reduce the size of the log file to less than 15 MB from GB execute the below mentioned script.

USE DatabaseName;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DatabaseName
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DatabaseName_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE DatabaseName
SET RECOVERY FULL;
GO

For more such interesting technology related blogs, resources visit my site https://sharetechlinks.com/

Tech Enthusiast, Full Stack Software Engineer, Product Manager, Engineering Enterprise SaaS product

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store