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
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