[英]Storing some special characters in SQL Server tables
我有以下查询:
update Qtable
set Q1 = ' If the alternative
hypothesis is as Ha : µ ≠µ0 ;
where QID = '856'
Q1
的数据类型为nvarchar(max)
。
现在我在数据库中更新并看到不是Ha : µ ≠µ0
,我得到
Ha : µ ?µ0
不知道为什么更新语句用 ≠ 替换? 我知道它是一个特殊字符,但是应该应用哪些设置来保留该值?
您需要确保为 Unicode 字符串文字加上 N 前缀。 像这样:
update Qtable set Q1=' If the alternative
hypothesis is as Ha :'+ N'µ ≠µ0' ;
where QID='856'
QUERY 1:(旧查询的字符串)
SELECT 'If the alternative
hypothesis is as Ha:µ ≠µ0';
输出:
If the alternative hypothesis is as Ha:µ ?µ0
QUERY 2:(新查询的字符串)
SELECT 'If the alternative
hypothesis is as Ha:' + N'µ ≠µ0';
输出:
If the alternative hypothesis is as Ha:µ ≠µ0
FOR DEMO 检查以下链接:
如果您不使用 NVARCHAR,那么您的not equal character
将被其他字符替换。
Nvarchar 存储 UNICODE 数据。 如果您需要存储 UNICODE 或多语言数据,nvarchar 是您的选择。 Varchar 存储 ASCII 数据,应该是您正常使用的数据类型选择。
使用此语句:
update Qtable
set Q1 = N'If the alternative hypothesis is as Ha : µ ≠µ0'
where QID = '856'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.