Why is % forbidden char in THROW message? Simple question:

THROW 50000, 'Because of this -&gt;%&lt;- is this message invisible.', 1;



you can't pass %s, %d parameters as in RAISERROR
you have to use FORMATMESSAGE
but THROW failed anyway if % is not doubled (correct displaying)


Tested on Microsoft SQL Server 2012 (SP1) 11.0.3381.0 (X64), 11.0.3000.0 (X64)



Real world example:

DECLARE @ProcParam VARCHAR(30) = 'Hehe%x!';
DECLARE @Message VARCHAR(500) = FORMATMESSAGE('Procedure input %s is wrong', @ProcParam);
PRINT 'Message: ' + @Message;
THROW 50000, @Message, 1;
It appears that they left the printf functionality (or at least part of it) in the THROW command but did not include a way to pass in a parameter to it.  I tried each of the characters listed in BOL for RAISEERROR as possible "types" %(d, i, o, s, x, X, or u) and each of them gave back a blank.  Any other character after the % and you get back a valid string.  My guess is that they are replacing the value with a NULL which of course causes any string concatenation to return a NULL and when printed looks blank.

Unfortunately without the code behind it (or at least a MS Developer) to confirm there is no way to be certain.