It is good. However, hard-coded WHILE (@no < 7)
There are times you need more than 7 log files, for example, SOX may require to retain a year data.
This parameter needs to read all logs or can be overridden by caller.:-P
Thank you for your thoughts. This script is intended for daily use / monitoring of the SQL error log(s), not for storing/archiving them. You are right, however, that even within 24 hours, more than 7 error logs could have been created, e.g. through several reboots/restarts of the SQL engine. I have at one time included code to determine the max number of error logs, using master.dbo.xp_instance_regread. That works well on a default instance, but needs additional coding in the case of a named instance. I'll look into it for a future version.