SQL Server – Cycle Error Logs for SQL Server and SQL Server Agent
SQL Server error logs can fill up quickly, and when you are troubleshooting something you may need to go through huge log. However you can cycle the error log to manage the amount of log you need to go through. When you cycle error log the current log file is renamed from ERRORLOG to ERRORLOG.1, ERRORLOG.1 is renamed to ERRORLOG.2 and so on.
Restarting SQL Server will cycle the error logs. You can also use sp_cycle_errorlog to cycle error logs without restarting SQL Server.
Below is an example how to use it:
EXEC sp_Cycle_ErrorLog
GO
Result Set:
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
You can verify that the log has cycled using Management Studio or you can use xp_ReadErrorLog also.
Same effect can be achieved by using DBCC ErrorLog. In fact, sp_Cycle_ErrorLog calls DBCC ErrorLog to cycle error logs.
DBCC ErrorLog
GO
Result Set:
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
DBCC ErrorLog and sp_Cycle_ErrorLog only cycles SQL Server error logs. It does not cycle SQL Server Agent error logs. In order to achieve this you can restart SQL Server Agent or use another stored procedure sp_Cycle_Agent_ErrorLog.
USE [msdb]
GO
EXEC sp_Cycle_Agent_ErrorLog
GO
Result Set:
Command(s) completed successfully.
You can verify that the SQL Server Agent log has cycled using xp_ReadErrorLog.
* Use sp_helptext to see what is called from sp_Cycle_Agent_ErrorLog.
Hope This Helps!
Vishal
If you like this post, do like my Facebook Page -> SqlAndMe
EMail me your questions -> Vishal@SqlAndMe.com
Follow me on Twitter -> @SqlAndMe
-
May 1, 2013 at 10:48 am | #1SQL Server – Finding TCP Port Number SQL Instance is Listening on | Sql And Me
Leave a Reply Cancel reply
Recent Posts
- SQL Server – Show/Hide Results Pane in Management Studio 2012
- SQL Server – How to Move Table to Another Schema
- SQL Server – How to find Default data and log path for SQL Server 2012
- SQL Server – Finding TCP Port Number SQL Instance is Listening on
- SQL Server – How to check if you are running 32-bit or 64-bit version
- SQL Server – Differences between Clustered and Non-Clustered Indexes
- SQL Server – Import Data from Excel using T-SQL
- SQL Server – Add Date/Time to output file of BCP / SQLCMD (2)
- SQL Server – Add Date/Time to output file of BCP / SQLCMD
- SQL Server – Saving Changes Not Permitted in Management Studio
Disclaimer
This is a personal weblog. The opinions expressed here are my own and not of my employer. For accuracy and official references refer to MSDN, Microsoft TechNet, Books Online. I or my employer do not endorse any of the tools / applications / books / concepts mentioned here on my blog. I have simply documented my personal experiences on this blog.
Categories
- Backup & Recovery (9)
- Catalog Views (18)
- Certification (1)
- Common Table Expressions (6)
- Database Mail (1)
- Management Studio (30)
- Management Views and Functions (10)
- Partitioning (3)
- Service Pack Releases (2)
- SQL Agent (4)
- SQL Bugs (2)
- SQL Configuration (23)
- SQLServer (143)
- SQLServer 2005 (98)
- SQLServer 2008 (101)
- SQLServer 2008 R2 (102)
- SQLServer 2012 (42)
- Uncategorized (1)
- Undocumented Functions (18)
- Working With Data (9)

