在MS SQL中插入上标数字 [英] Inserting Superscript Numbers in MS SQL
问题描述
试图在varchar
数据字段中插入一个值,该值的最后一个上标数字为4(幂为4).
Trying to insert a value into a varchar
data field with the Superscript number of 4 (power of 4) at the end.
我能够使用上标2和3(即平方和立方)来插入/更新值,但是我无法获得4的幂以正确输入varchar
字段?
I'm able to insert/update values using superscript 2 and 3 (ie squared and cubed), but I can't get the power of 4 to enter correctly into a varchar
field?
如果我将字段切换为nvarchar
,它确实可以工作,但是我正试图避免这种情况.
It does work if I switch the field to a nvarchar
, but I'm trying to avoid that.
这适用于平方或2的幂次
This works for squared or to the power of 2
update mytable
set myfield = 'test'+NCHAR(0xb2)
但是,尝试使它最后使用4来工作...
However, trying to get this to work using a 4 at the end...
update mytable
set myfield = 'test'+NCHAR(0x2074)
它只是将其更新为数字4,而不是上标4.这是因为VarChar
数据类型可以识别平方和立方,但不能识别其他任何数据吗?
It just updates it a numeric 4 and not superscript 4. Is this because the VarChar
datatype recognizes squared and cubed, but not any other ones?
推荐答案
3以上的上标仅作为Unicode字符提供,因此,不幸的是,您需要在数据字段中使用NVARCHAR
而不是VARCHAR
.
Superscripts beyond 3 are only available as Unicode characters, so you need to use an NVARCHAR
instead of a VARCHAR
for your data field, unfortunately.
如果不使用NVARCHAR
,请参见 ASCII表以获取允许的字符-您只会看到2和3的上标.
Please see the ASCII table for allowable characters without using NVARCHAR
- You'll only see superscripts for 2 and 3.
这篇关于在MS SQL中插入上标数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!