sql raiserror指定参数 [英] sql raiserror specify parameter

查看:168
本文介绍了sql raiserror指定参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我阅读MSDN raiserror的示例时:

When i read the example of MSDN 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

为什么文档使用%s指定N'number',并使用%d指定5-第二个参数

Why the doc using %s to specify the N'number',and %d to specify the 5 -- Second argument

MSDN这样写:

例如,在下面的RAISERROR语句中,N'number'的第一个参数替换%s的第一个转换规范;并且第二个参数5替换了%d的第二个转换规范.

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

我的问题是:如何解释?为什么不使用其他%a%b,其他任何%+apha都可以替换. 我只是想获得有意义的理解.

My question is: How can explain it? Why don't using other like %a or %b.Any other %+apha can replace it. I just want to get a meaningful understand.

推荐答案

这代表参数数据类型.

+--------------------+----------------------+
| 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表示.

N'number' is an nvarchar string literal. So gets the %sspecifier. And the literal 5 is a signed indicator so is represented by %d.

由于这些说明符的原因.记录在 RAISERROR 主题

As for the reason for these specifiers. This is documented in the RAISERROR topic

这些类型规范基于最初为 C标准库中的 printf 函数

These type specifications are based on the ones originally defined for the printf function in the C standard library

这篇关于sql raiserror指定参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆