替换 MS SQL Server 中的特定 Unicode 字符 [英] Replacing a specific Unicode Character in MS SQL Server

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

问题描述

我使用的是 MS SQL Server Express 2012.

I'm using MS SQL Server Express 2012.

我无法删除 unicode 字符 U+02CC(十进制:716)在网格结果中.原文为'λeˌβár'.

I'm having trouble removing the unicode character U+02CC (Decimal : 716) in the grid results. The original text is 'λeˌβár'.

我是这样试的,没用:

SELECT ColumnTextWithUnicode, REPLACE(ColumnTextWithUnicode , 'ˌ','') 
FROM TableName

该列具有 Latin1_General_CI_AS 排序规则,数据类型为 nvarchar.我尝试将排序规则更改为二进制文件,但也没有成功:

The column has Latin1_General_CI_AS collation and datatype is nvarchar. I tried changing the collation to something binary, but no success as well:

SELECT ColumnTextWithUnicode, REPLACE(ColumnTextWithUnicode collate Latin1_General_BIN, 'ˌ' collate Latin1_General_BIN,'') 
FROM  TableName

或者甚至使用 NChar() 函数,例如:

Or even using the NChar() function like:

SELECT ColumnTextWithUnicode, REPLACE(ColumnTextWithUnicode , NCHAR(716),'') 
FROM TableName

所有三个的结果都是λeˌβár".

The results are 'λeˌβár' for all three.

但是如果我将列转换为 varchar ,例如:

But if I cast the column to varchar like:

SELECT ColumnTextWithUnicode, REPLACE(CAST(ColumnTextWithUnicode as varchar(100)), 'ˌ','') 
FROM TableName

结果变成了 'eßár',同时删除了第一个字符和 'ˌ'.

the result becomes 'eßár', removing both the first character and 'ˌ'.

有什么想法可以只删除ˌ"?

Any ideas to remove just the 'ˌ'?

推荐答案

你也只需要在字符串模式前加上 N(如果你想找 unicode 字符):

you just need to put N before string pattern too (if you want look for unicode char):

SELECT REPLACE (N'λeˌβár' COLLATE Latin1_General_BIN, N'ˌ', '')

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

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