Skip to content

Instantly share code, notes, and snippets.

@Gaboso
Created September 13, 2021 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gaboso/d496bf7faf8107f9ebf4b576204cb84d to your computer and use it in GitHub Desktop.
Save Gaboso/d496bf7faf8107f9ebf4b576204cb84d to your computer and use it in GitHub Desktop.
Shrink SQL Server Example
USE DB_NEW;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DB_NEW
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE ('DB_NEW_log', 1);
GO
-- Reset the database recovery model.
ALTER DATABASE DB_NEW
SET RECOVERY FULL;
GO
USE DB_NEW;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DB_NEW
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE ('DB_NEW_Data', 1);
GO
-- Reset the database recovery model.
ALTER DATABASE DB_NEW
SET RECOVERY FULL;
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment