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


Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *