Thursday, August 24, 2006

Microsoft SQL Server: how to truncate the ERRORLOG

The Microsoft SQL Server error log is stored at c:/Program Files/Microsoft SQL Server/MSSQL/LOG/ERRORLOG (or similar). This can get very big, because it only recycles when the instance is restarted. When it's too big, it becomes difficult to parse it for errors.

When the instance restarts, the ERRORLOG is renamed to ERRORLOG.1 and a new ERRORLOG is started. As this hapens again and again, the number of the file increases.

You can force the ERRORLOG to recycle without restarting the instance with this simple command:




osql -S myserver -E -Q "exec sp_cycle_errorlog"


Or, of course, you can run the command "exec sp_cycle_errorlog" from Query Analyzer.

1 comment:

I moderate comments blog posts over 14 days old. This keeps a lot of spam away. I generally am all right about moderating. Thanks for understanding.