SQL Tip-1 | Don’t forget to recycle your SQLServer ErrorLog
Many a times I’ve seen that DBAs forget to recycle the ErrorLog of their critical SQLServers. Now I also understand that SQLServer Error Log is very important & can help you troubleshoot many issues so in theory there is nothing wrong with a large Error Log but at times this could be very frustrating.
Let’s assume you are trying to resolve a severity case and already under pressure – giving updates to n number of people on a Bridge Call, handling multiple pings from Higher management\Clients and at the same time making sure you resolve the issue within your SLA.
Now between all of this, you need to get some info from your SQL Server error log, you issue the command sp_ReadErrorLog and wait for your log to get loaded and then it keeps on loading which takes 3-4 minutes to load. I am sure you won’t be able to afford this wait, obviously you can also open the file in Notepad but that will also take some time depending on the size of file & you must be on the same server and also need to locate the folder.
Since SQL Server will recycle Error Log only at the time of starting the service until and unless you’ve recycled it explicitly. The best option would be to recycle the errorlog manually on a certain interval (based on the usage & growth rate) .
You can use any one out of the two below mentioned commands in order to recycle Error Log.
This command will just recycle the errorlog of your SQL Server without any restart, which means if you are recycling your errorlog every 7 days – you’ll be having a fresh errorlog every 7th day without any downtime and your last errorlog will be archived & renamed to ErrorLog.1
Note: Make sure you also increase the log retention limit before recycling your errorlogs, To know more read: Do you know you can increase number of archived Errorlogs
Sarabpreet Singh Anand
Subscribe now to get latest Tips in your Inbox