Truncate or Shrink a SQL Server log file


Many ways you can shrink the log file, some trick is given below.

1. Management studio:
  • Don't do this in a live environment, but to ensure you shrink your dev db as much as you can:
  • Right-click the database, choose properties, then options.
  • Make sure "Recovery model" is set to "Simple", not "Full"
  • Click Ok
  • Right-click the database again, choose tasks -> shrink files
  • Change the file type to "log"
  • Click ok.
2. By Command you can do as below


ALTER DATABASE YourDatabaseName SET RECOVERY SIMPLE
DBCC SHRINKFILE('YourDatabaseName_log', 0, TRUNCATEONLY)

No comments:

Post a Comment

Please do not enter any spam link in the comment box.

Related Posts

What is the Use of isNaN Function in JavaScript? A Comprehensive Explanation for Effective Input Validation

In the world of JavaScript, input validation is a critical aspect of ensuring that user-provided data is processed correctly. One indispensa...