How to clean log file od a SQL server Database

We are always see that our database file(.mdf) is very low, but the log file is too high nearly 10-100% high or more. One day i saw in our company database, the .mdf file is nearly 500MB but the log file is 35GB. So i tried to clean the log file and got the solution from one of sql server ebooks. So i place that code here to help those people who are having this problem.

Code



USE
GO
DBCC SHRINKFILE(, )
BACKUP LOG WITH TRUNCATE_ONLY
DBCC SHRINKFILE(, )


You can change database name, TransactionLogName and file size as per your requirement.

For Example :



USE dbproduct
GO
DBCC SHRINKFILE(dbproduct_log, 10)
BACKUP LOG dbproduct WITH TRUNCATE_ONLY
DBCC SHRINKFILE(dbproduct_log, 10)


Thank You.

Regards,
Manoranjan Sahoo


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: