Sql raiserror specify parameter

When I read the MSDN example raiserror:

RAISERROR (N'This is message %s %d.', -- Message text.
           10, -- Severity,
           1, -- State,
           N'number', -- First argument.
           5); -- Second argument.
-- The message text returned is: This is message number 5.
GO

Why does doc use %sto indicate N'number'and %dto indicate the 5second argument

MSDN records the following:

For example, in the following RAISERROR expression, the first argument N'number 'replaces the first conversion specification% s; and the second argument 5 replaces the second conversion specification% d.

My question is: how to explain this? Why not use others such as %aor %b. Anyone else %+aphacan replace it. I just want to understand the meaning.

+3
source share
1 answer

This represents the parameter data type.

+--------------------+----------------------+
| Type specification |      Represents      |
+--------------------+----------------------+
| d or i             | Signed integer       |
| o                  | Unsigned octal       |
| s                  | String               |
| u                  | Unsigned integer     |
| x or X             | Unsigned hexadecimal |
+--------------------+----------------------+

N'number' nvarchar. %s. 5 , %d.

. RAISERROR

, printf C

+4

Source: https://habr.com/ru/post/1661832/


All Articles