Closed PardhaGanta closed 2 days ago
DatabaseIntegrityCheck is executing CommandExecute with @Mode = 1
. This means that it is using the @@ERROR
variable. Unfortunately there is no way to check the error message in that way.
You will have to check the error details in the output - file.
We have deployed ola hallangren maintenance scripts in our environment(SQL Versions 2016/2019). We noticed a record in commandlog table with text similar to 'DBCC CHECKDB (databasename) WITH all_errormsgs, no_infomsgs, data_purity executed by xxxxx found 7 errors and repaired 0 errors' , Error is 2508 but Errormessage is null. We want to capture the errormessage for the errornumber 2508.
I have analysed the Ola Hallangren scripts that are used to create our Maintenance Jobs. This part of code within ‘commandexecute’ stored proc should have caught the error message unless I am missing something.
IF @LogToTable = 'Y' BEGIN UPDATE dbo.CommandLog SET EndTime = @EndTime, ErrorNumber = CASE WHEN @Execute = 'N' THEN NULL ELSE @Error END, ErrorMessage = @ErrorMessageOriginal WHERE ID = @ID END
SQL Server version is 2019