Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakline in Raiseerror

Tags:

sql

sql-server

is there anyway to breakline and continue on next line in RaiseError? <br/> and /n aren't working

Below is my code:

BEGIN
BEGIN TRY
    SELECT 16/0
END TRY
BEGIN CATCH
    WHILE(@Count != 0)
    BEGIN
        SET @MaterialName = (SELECT Material FROM #T WHERE Quantity = 0 AND ID = @Count)
        SET @MSG = 'Material %s was not offered.' 
        RAISERROR(@MSG,16,1,@MaterialName);
        SET @Count = @Count - 1
    END
END CATCH
END

I dont want to make changes in the data access layer, we only support web, not window app. I want each loop msg to be printed on next line using sql only. Is it possible?

like image 250
Wocugon Avatar asked Jul 05 '26 04:07

Wocugon


1 Answers

if you include the line break in the text it will work.

SET @MSG = 'Material %s was not offered.
' 

Note that the end quote is on a new line.

like image 153
PatFromCanada Avatar answered Jul 06 '26 18:07

PatFromCanada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!