Created
January 27, 2015 02:18
-
-
Save gildotdev/d170dd5423fbd6a2ab5c to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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