I see something new to me, stored procedures that print debug messages by raising errors of low severity:
raiserror (@Message, 10 , 1) with nowait
If my stored procedure is initiated with the following batch command:
SQLCMD.EXE -E -S%SqlServer% -d %DatabaseName% -b -Q "dbo.usp_Myproc" >> "%LogFile%"
I am presuming that these “error messages” are logged to the file %LogFile%
Is this the case? Would T-SQL PRINT statement do the same, I presume not.
Is this a reasonable approach/what is a better way to log?
low severity raiserror messages are written to the log file but then again, so are PRINT messages. Therefore, I question why anyone would choose to raise a low severity error message to write informational messages that are not really errors. My suspicion is that they were not aware of the PRINT command, didn’t think to use it or didn’t care as long as it served their purpose.