top of page
Writer's picturerajendra gupta

T-SQL script to Recycle SQL Server error logs manually

Updated: Dec 30, 2021

SQL Server allows you to automatically recycle error logs and this is great because it gives you more of a hands-off approach. However, if you require to do it manually, you can use the stored procedure sp_cycle_errorlog as shown below.


Once you execute the following T-SQL script, it creates a new error log file and start recording latest entries into it.


Use Master
Go
EXEC sp_cycle_errorlog
GO

Similarly, the following script recycles the SQL Server agent error log file.


USE msdb ; 
GO  
EXEC dbo.sp_cycle_agent_errorlog ;  
GO

If you are looking to manage SQL Server logs effectively, refer to the article - https://www.sqlshack.com/how-to-manage-sql-server-logs-effectively/

Recent Posts

See All

Comments


bottom of page