Friday , November 22 2024

How To Recycle Error Log Without Restarting SQL Server Service

 

In some cases, the SQL Server Error Log File grows very fast. And when the file grows too large, it becomes difficult to read.

Before you read this article, I suggest you read articles “How To Filter SQL Server Error Log(Like or Not Like)” and “How to Increase SQL Server Error Log File Count“.

Some DBAs are restarting the SQL Server Service to create a new Error Log file when the Error Log file is too large. Because a new log file occurs when SQL Server Service restarts.

Below you see Current is our current error log file. The date next to it is the date the file was created.

 

This means that; SQL Server Service restarted on 23.9.2016, or a person might have consciously created a new file. The subject of this article is to create a new file without restarting the sql server service.

We are performing the recycle process by running the following script.

 

When we right-click on SQL Server Logs and click refresh, we see that a new file is created. When I ran this script, it was 10:55.

If your SQL Server does not restart for a long time, you can convert this script to a job and run it once a month or once every 3 months. You can use the article titled “How To Create a SQL Server Job

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *