Sample Header Ad - 728x90

Sql Server: Raise warnings and collect them

0 votes
2 answers
1011 views
I need to raise one or more warning messages inside a child stored procedure and then collect all of them in the parent one. I tried with RAISERROR('Message 1',0,0) WITH NOWAIT but it doesn't work at all (ERROR_MESSAGE() is NULL in the code below). I wish something like code below, which is not working. It doesn't have to be RAISERROR, any solution is accepted. create procedure test_child as begin RAISERROR('Message 1',0,0) WITH NOWAIT; RAISERROR('Message 2',0,0) WITH NOWAIT; RAISERROR('Message 3',0,0) WITH NOWAIT; end ; create procedure test_parent as begin declare @err nvarchar(max); exec test_child; set @err = error_message(); select @err end ; exec test_parent;
Asked by Radioleao (153 rep)
Nov 2, 2022, 11:06 AM
Last activity: Nov 3, 2022, 03:29 PM