New answers tagged error-handling
The code you have posted already does what you want as written. Errors you raise yourself with RAISERROR do not abort the batch, not even in trigger context. You will see that in the screenshot below SSMS manages to display all errors fine. Are you missing some context in your question?
One method is to build an error message string and issue a single RAISERROR conditionally after all validations are done. DECLARE @ErrorMessage varchar(2047); IF @ForeCastYearCheck = 'false' SET @ErrorMessage = @ForeCastYearCheckError; IF @ForeCastQuarterCheck = 'false' SET @ErrorMessage = COALESCE(@ErrorMessage + ',' + @ForeCastQuarterCheckError, ...
Top 50 recent answers are included