Truncate Log file in SQL Server



I got an issue with my database.  Entire database is hanging and I didn't find an option to think the reason for this issue. We are unable to do any transaction. On checking the log file, we found the issue lies with log files.
 
   1. Log file is around 20MB size with restricted growth option set for the database.
 
Solution:
 
  1. I have changed the option to have un restricted growth.
  2. Backup the database before doing truncate option.
  3. Truncated the log file.
 
USE VenkatDB;
GO
 
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE VenkatDB SET RECOVERY SIMPLE;
GO
 
-- Shrink the truncated log file to 1 MB.
 
DBCC SHRINKFILE (VenkatDB _Log, 1);
GO
 
-- Reset the database recovery model.
 
ALTER DATABASE VenkatDB SET RECOVERY FULL;
 
GO

 
Cheers,
Venkatesan Prabu .J
Ebook Download
View all
Learn
View all