Peter E. Kierstead (2/20/2008)
The previous poster is correct about using RAISERROR as opposed to PRINT to eliminate output queing, however, RAISERROR has a feature that my cause you problems if you are not aware of it. The output string uses a format similar to the C printf function in that it supports % format strings. If you don't escape your use of % signs the RAISERROR call will fail. You can do this by doubling up all % signs in your original string before outputing it.The following will fail...
Declare @Msg VarChar(8000)
Set @Msg='''%'' is an invalid input.'
RaisError(@Msg,0,1) with nowait
Corrected version...
Declare @Msg VarChar(8000)
Set @Msg='''%'' is an invalid input.'
Set @Msg=Replace(@Msg,'%','%%')
RaisError(@Msg,0,1) with nowait
You could write an OUTPUT procedure to handle these details for you...
There is a simpler way:
RaisError('%s',0,1, @Msg) with nowait
No need for any escaping.
_____________
Code for TallyGenerator