RAISERROR Percent % Sign usage
Have you ever wondered how to build a string with values for an error message? One would think that RASIERROR could simply take a string that was concatenated together with variables.
Something like RAISERROR ('My Error' + @myErrorString, 16,1)
Unfortunately, RAISERROR is not as intuitive as this.
The syntax for RAISERROR is:
RAISERROR ({msg_id | msg_str}{, severity, state}
[, argument
[,...n]] )
[WITH option[,...n]]
Maybe you have seen the arguments passed into the error message string with percent sign.
RAISERROR ('My Error %s', 16,1, @myErrorString)
The % sign indicates the use of a parameter.
To pad some space a number must be placed infront of the type.
RAISERROR ('My Error %10s', 16,1, @myErrorString,@myErrorString2)
To justify simply use the + or - sign after the % sign. To pad with a space, use `` (next to the 1 key)
If you pass more than one argument then you must use the percent signs in order.
RAISERROR ('My Error %10s is not cool %10s', 16,1, @myErrorString,@myErrorString2)
Something like RAISERROR ('My Error' + @myErrorString, 16,1)
Unfortunately, RAISERROR is not as intuitive as this.
The syntax for RAISERROR is:
RAISERROR ({msg_id | msg_str}{, severity, state}
[, argument
[,...n]] )
[WITH option[,...n]]
Maybe you have seen the arguments passed into the error message string with percent sign.
RAISERROR ('My Error %s', 16,1, @myErrorString)
The % sign indicates the use of a parameter.
| d or i | Signed integer |
| o | Unsigned octal |
| p | Pointer |
| s | String |
| u | Unsigned integer |
| x or X | Unsigned hexadecimal |
To pad some space a number must be placed infront of the type.
RAISERROR ('My Error %10s', 16,1, @myErrorString,@myErrorString2)
To justify simply use the + or - sign after the % sign. To pad with a space, use `` (next to the 1 key)
If you pass more than one argument then you must use the percent signs in order.
RAISERROR ('My Error %10s is not cool %10s', 16,1, @myErrorString,@myErrorString2)


zvraruax http://lipqjqdi.com xqfmljpb zduzrfbw
Reply to this