Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear error logs using query in SQL Server without restarting the instance?

How to clear error logs using a query in SQL Server without restarting the server instance?

like image 640
Rushang Avatar asked Jan 04 '17 08:01

Rushang


3 Answers

Reference : How to Recycle SQL Server Error Log file without restarting SQL Server Service

Use [master];
GO

SP_CYCLE_ERRORLOG
GO
like image 162
anon Avatar answered Oct 12 '22 22:10

anon


clear error logs using a query in SQL Server without restarting the server instance:

SP_CYCLE_ERRORLOG

After run the command, please check: "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log" and delete old file (like: ERRORLOG.1, ERRORLOG.2 ...). I open SQL port 1433, so my ERRORLOG about 20Gb. Some one scan my Sql password. Don't open port 1433 to internet.

like image 40
Datusa Avatar answered Oct 12 '22 22:10

Datusa


You can run: sp_cycle_errorlog

That will start a new log file.

If you want to really delete log entries, you'd have to run that command seven times. By default there are seven logs cycled through. But often DBAs change that to maximum possible of 99.

like image 34
Mark Varnas Avatar answered Oct 12 '22 22:10

Mark Varnas