Skip to content

Instantly share code, notes, and snippets.

@bradleykronson
Created February 29, 2024 13:06
Show Gist options
  • Save bradleykronson/59864c92df82abec6e25f7e68afea05c to your computer and use it in GitHub Desktop.
Save bradleykronson/59864c92df82abec6e25f7e68afea05c to your computer and use it in GitHub Desktop.
Shink SQL Database
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
-- source
-- https://stackoverflow.com/questions/829542/how-do-i-decrease-the-size-of-my-sql-server-log-file/829573#829573
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment