Sample Header Ad - 728x90

SQL Server - What is the RAISERROR substitution parameter for boolean/bit type?

0 votes
0 answers
3010 views
I'd like to quickly dump some context into an error message including some boolean flags using the handy-dandy substitution parameters of RAISERROR such as CREATE PROCEDURE MyProc ( @param1 INT = 1, @param2 VARCHAR(255) = 'hello world' ) AS BEGIN ... RAISERROR('Inconsistent state occurred processing @param1=%d @param2=%s', 16, 1, @param1, @param2) ... END According to the documentation there is no type specification for bit type (boolean), but notes that > These type specifications are based on the ones originally defined for the printf function in the C standard library. And as this post notes, > ... since any integral type shorter than int is promoted to int when passed down to printf()s variadic arguments, you can use %d But it does not work in SQL, as I get the following error (2748): > Cannot specify bit data type (parameter ###) as a substitution parameter. Am I forced to use a helper variable? Thanks. P.S. Using compatibility mode for 2008R2.
Asked by Elaskanator (761 rep)
Jun 25, 2018, 09:25 PM
Last activity: Jun 25, 2018, 09:31 PM