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

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


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.


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.