Display local variable in while loop
There are two extensions of RAISERROR that may help:

To write it to the error log:

DECLARE @msg NVARCHAR(1000) = N''
RAISERROR(@msg, 16, 1) WITH LOG;


To display it in the messages tab in "real time":

DECLARE @msg NVARCHAR(1000) = N''
RAISERROR(@msg, 16, 1) WITH NOWAIT;