SQL中的特殊字符 [英] Special Character in SQL

查看:257
本文介绍了SQL中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SQL Server 2008 R2的表中插入特殊字符时遇到问题. 关键是,当我尝试在表中插入带有字符º(例如3 ELBOW90ºLONG RADIUS)的字符串时,它看起来像这样:3 ELBOW 90.LONG RADIUS,并且当我尝试选择所有包含字符的行-结果为null.

I have a problem with a special character inserted in a table of SQL Server 2008 R2. The point is that when i'm trying to insert a string with the character º (e.g. 3 ELBOW 90º LONG RADIUS) in the table this appears like this: 3 ELBOW 90� LONG RADIUS, and when i'm trying to select all the rows that contains the character � the result is null.

我尝试通过以下方式使用ASCII进行选择: 从项目代码中选择*,描述类似于'%'+ char(63)+'%'

I tried to make the select with ASCII by making this: select * from itemcode where description like '%'+char(63)+'%'

并使其知道该符号的ASCII为63:

and make this to know that the ASCII of that symbol is 63:

选择ASCII(' ')

select ASCII('�')

但这不起作用. 我应该怎么做才能选择所有具有该字符的行,我应该怎么做才能使该SQL识别字符º?

But that doesn't work. What i must do to select all the rows that have that character and what should i do to make that SQL recognize the character º?

谢谢

推荐答案

度数符号

U+00B0 ° degree sign (HTML: ° °)

不是ASCII字符,通常需要NVARCHAR列和N''字符串文字. (除了支持该符号的代码页等)

is not an ASCII character and generally requires an NVARCHAR column and a N'' string literal. (except for codepages etc that support the symbol)

63是问号的代码,这是您的反向问号的后备ASCII:

63 is the code of the question mark, which is the fallback for your inverse question mark in ASCII:

select UNICODE('�') => 63
select UNICODE(N'�') => 65533

其中65533是用于显示的 Unicode替换字符无法转换或显示的字符.

where 65533 is the Unicode Replacement Character used to display characters that could not be converted or displayed.

这篇关于SQL中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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