If I understand correctly, the above code is printed out when the stored procedure runs.
I would start by modifying the stored procedure to take an output parameter. Stored procedures "return" integer values, not messages. They happen to print things out, but it is not good to depend on that behavior.
Then, you can simply do:
declare @str nvarchar(max);
exec <stored procedure> @str output;
exec @str;
I suspect there might be a better way to structure the code. Having stored procedures return code should only be done when you really understand what you are doing. I don't think I've ever written code where a stored procedure would return an insert statement. It seems better to run dynamic SQL in the stored procedure itself.
EDIT:
You can capture the output of the stored procedure as well:
declare @t table (id int identity, line nvarchar(max));
insert into @t(line)
exec(<stored procedure>);
Then, you can concatenate the values. You can use XML for this purpose, but I think this will work:
declare @str nvarchar(max);
set @str = '';
select @str = @str + line + ' '
from @t
order by id;
exec @str;