Created
September 13, 2021 15:20
-
-
Save Gaboso/d496bf7faf8107f9ebf4b576204cb84d to your computer and use it in GitHub Desktop.
Shrink SQL Server Example
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 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