XP_READERRORLOG or SQL SERVER ERRORLOG


We can search error log with the below mentioned extended stored procedure the main thing we need to remember here is ""(double quotes) and the date format should be YYYY-MM-DD


The below powershell query will fetch the SQL Server error log information. It will read all error log files.
cls
Get-ChildItem -Path "D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log" -File -Name -Include ERRORLOG*|
ForEach-Object {
$IndFile = $_ 
$filters = @("offline","Database1","Database2","Database3")
$inputFile = "D:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log\$IndFile"
Get-Content $inputFile | Select-String -pattern $filters -AllMatches
}

Comments

Popular posts from this blog

Always On FailOver Events

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

Pre login Handshake or Connection Timeout Period