How to reduce/shrink the SQL file size

June 16, 2024 / MySQL

Reducing/shrinking the SQL file size is essential for optimising database performance, saving storage space, and confirming efficient data management.

Follow the steps-

  1. Open SQL Server Management Studio and right-click on the database.
  2. Choose “Properties” > “Options”.
  3. Set “Recovery mode” to “Simple” and click OK.
  4. Right-click the database again, choose “Tasks” > “Shrink” > “Files”.
  5. Change the file type to “Log”.
  6. Set the log file size to 100 MB and click OK.
  7. Check the folder to confirm the size reduction.
  8. Alternatively, use these SQL queries-
    ALTER DATABASE mydatabase SET RECOVERY SIMPLE;
    DBCC SHRINKFILE (mydatabase_Log, 1);Warning – The first SQL script targets the main database, while the second script targets the log database.
    After completing these steps, check if the folder size has been reduced.

Note – Revert the “Recovery mode” from Simple to Full after shrinking the log file.

This concludes our article. We hope you found it helpful. If you enjoyed the article, you will definitely appreciate our support services.

Spread the love