1. Login to the SQL server 2005 under "sa" login. Then run the following command
2. Take a full backup of the database.
3. Now run the following.
USE <write the database name>;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE <write the database name>
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 10 MB.
DBCC SHRINKFILE (<Database Logical Name>, 10);
GO
-- Reset the database recovery model.
ALTER DATABASE <write the database name>
SET RECOVERY FULL;
GO
NOTE : if the database recovery model was originally SIMPLE, then change it to SIMPLE after running the above script.
But if it is originally "FULL", then no need to change it again. Because the above script automatically change it to "FULL".
That is useful script that will help me shrink database log files, especially although the recovery mode is simple log data increases immersely
ReplyDelete