如何使用带有 unicode 字符串的“LIKE"语句? [英] How to use 'LIKE' statement with unicode strings?

查看:27
本文介绍了如何使用带有 unicode 字符串的“LIKE"语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 unicode 字符执行查询.我能够通过在查询前添加 N(例如:..... WHERE column=N'exact_stringâ')来执行正常的等式查询.但是当我尝试使用 LIKE 时,这似乎不起作用.关于如何完成这项工作的任何想法?

I am trying to execute a query with unicode characters. I was able to execute the normal equality query by prepending N to the query (Eg: ..... WHERE column=N'exact_stringâ'). But that doesn't seem to work when I try to use LIKE. Any ideas on how to make this work?

示例查询:SELECT * FROM t_sample WHERE t_column LIKE N'%â%'

另外,我如何知道 SQL Server 使用哪种编码来存储 nvarcharnchar 数据类型以及它使用哪种编码在 SQL 编辑器中显示查询?

Also how can I know which encoding does the SQL Server use to store the nvarchar or nchar data type and what encoding it uses to show the query in SQL Editor?

我的错.这实际上有效.我尝试在错误的窗口中执行查询.但这样做的好处是我了解了 SQL Server 中的排序规则设置.

My bad. This actually works. I have tried executing the query in a wrong window. But the upside of this is that I learned about Collation settings in SQL Server.

推荐答案

确保您的表上的排序规则支持 unicode.

Make sure the collation on your table supports unicode.

这篇关于如何使用带有 unicode 字符串的“LIKE"语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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