What is the meaning of an quot;Nquot; before quotes in a SQL Server assignment?(“N是什么意思?在 SQL Server 分配中的引号之前?)
问题描述
我正在查看的代码是这样的:
The code I am looking at is this:
SET @Message = N'Question result is ''' + @CurrentResult + '''. It should be unmarked or incorrect';
THROW 50002,@Message,1
谁能解释一下为什么开发人员在引号前加了N"?
Can someone explain why the developer but "N" before the quotes?
推荐答案
来自 MSDN在备注部分
说字符串是 Nvarchar 类型并且可以有 unicode 字符
Saying that string is of Nvarchar type and can have unicode charcters
用字母 N 前缀 Unicode 字符串常量.没有N 前缀,字符串被转换为默认代码页数据库.此默认代码页可能无法识别某些字符.
Prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.
"N" 前缀代表 SQL-92 标准中的国家语言,必须大写.如果不使用 N 作为 Unicode 字符串常量的前缀,SQL Server 会在使用该字符串之前将其转换为当前数据库的非 Unicode 代码页.
The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.
这里有更详细的信息
在处理 Unicode 字符串常量时,必须在所有 Unicode 字符串前加上前缀 NSQL Server
这篇关于“N"是什么意思?在 SQL Server 分配中的引号之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“N"是什么意思?在 SQL Server 分配中的引号之前
基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
