Shrink the truncated log file on SQL Server
USE
[DatabaseName];
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER
DATABASE [DatabaseName]
SET
RECOVERY SIMPLE WITH NO_WAIT;
GO
-- Shrink the truncated log file to 1 MB.
DBCC
SHRINKFILE(DatabaseName_log, 1); --file_name is the logical name of the file to be shrink
GO
-- Reset the database recovery model.
ALTER
DATABASE [DatabaseName]
SET
RECOVERY FULL WITH NO_WAIT;
GO
[DatabaseName];
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER
DATABASE [DatabaseName]
SET
RECOVERY SIMPLE WITH NO_WAIT;
GO
-- Shrink the truncated log file to 1 MB.
DBCC
SHRINKFILE(DatabaseName_log, 1); --file_name is the logical name of the file to be shrink
GO
-- Reset the database recovery model.
ALTER
DATABASE [DatabaseName]
SET
RECOVERY FULL WITH NO_WAIT;
GO
Comments
Post a Comment