Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shrinking a log file to a specified target size The following example shrinks the log file in the AdventureWorks2008R2 database to 1 MB. To allow the DBCC SHRINKFILE command to shrink the file, the file is first truncated by setting the database recovery model to SIMPLE.
USE ExampleDB;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE ExampleDB
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (ExampleDB_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE ExampleDB
SET RECOVERY FULL;
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment