I have some code to help automate checking the error logs daily on our SQL Server. This code calls xp_readerrorlog 0 to check the error log, and xp_readerrorlog 0,1 to check the SQL Server log.
Sometimes, however, there is more than one error log I need to scan.
I would like to be able to see, by T-SQL, the date of the log or, barring that, find the number of logs that exist.
I read that we can have up to 99 archive logs, but the server throws the following error message when trying to display an error log that doesn't exist.
"xp_readerrorlog() returned error 2, 'The system cannot find the file specified."
I know the date information and number exists since SSMS displays it( see the image below.)