Monday, April 28, 2014

scape percentage (%) character in sp_addmessage

Good Afternoon!


Please forgive my English level.


I'm trying to scape a percentage simbol that I pass as a parameter in a RAISERROR control inside a stored procedured but it seems SQL Server read it as a variable.


My message is defined like this:



EXEC sp_addmessage @msgnum = 60001, @severity = 16,
@msgtext =
N'The quota filled with %s and the percentage filled with %s must be mutually exclusive, ie, if one of them is nonzero, the other must be zero.',
@lang = 'us_english',
@replace = 'replace';
GO



Then I run a RAISE error inside a stored procedure LIKE THIS:



RAISERROR(60001, -1, -1, N'$1,000,000.00', N'100.00%');



But i obtain the next error message when I execute the stored procedure:


Msg 2787, Level 16, State 1, Procedure pa_1, Line 204

Invalid format specification: '% must be mutually exclusive, ie, if one of them is nonzero, the other must be zero.'.

How can I scape the percentage (%) character inside the especification of the sql server stored procedure sp_addmessage to obtain the desired result


Thanks a lot for your valuable help.


No comments:

Post a Comment