The ERRORLOG files that you come across in the MS SQL logs folder can grow significantly in size and consume large amounts of storage over time.
You might be thinking the same thing I thought the first time I browsed to this location:
You can actually get away with this for the archived logs such as ERRORLOG.1, ERRORLOG.2, and so on.
Do not delete the active log file, which is simply named ERRORLOG.
Although manually deleting archived logs works, it isn't the recommended approach.
Instead, follow these steps to cycle the SQL Server error log safely.
Open SQL Server Management Studio (SSMS) and connect to your SQL Server instance.
Select Databases and click New Query.
Run the following command:
This stored procedure closes the current error log, archives it, and automatically creates a new active ERRORLOG. Existing archived logs are renamed sequentially.
Note that this command does not delete the archived log files. You'll still need to remove the older ERRORLOG.n files manually if you no longer need them.
For production environments, it's a good practice to automate this process as part of a regular maintenance job by periodically cycling the error logs and cleaning up old archived files.
#MSSQL #databases
0 Comments