Shrink the truncated log file on SQL Server

USE
 [DatabaseName];



GO




-- Truncate the log by changing the database recovery model to SIMPLE.




ALTER
DATABASE [DatabaseName]



SET
RECOVERY SIMPLE WITH NO_WAIT;



GO




-- Shrink the truncated log file to 1 MB.




DBCC
SHRINKFILE(DatabaseName_log, 1); --file_name is the logical name of the file to be shrink



GO




-- Reset the database recovery model.




ALTER
DATABASE [DatabaseName]



SET
RECOVERY FULL WITH NO_WAIT;



GO

Comments

Popular posts from this blog

SharePoint 2016 and 2019 Ports

PsConfig step by step /Configuration Wizard. “Upgrade Available” vs “Upgrade required”

Unlock the SharePoint site using Powershell command