SQL Server喜欢语句仅在插入一个Unicode字符时起作用(无多个字符起作用)
我有一些SQL查询,这样
SELECT ...
FROM ...
WHERE FIELD LIKE N'%ב%'
可以工作。但是,如果我插入更多字符,它甚至没有任何内容(该字段包含'בצע')
SELECT ...
FROM ...
WHERE FIELD LIKE N'%בו%'
和想法吗?谢谢!
I have some SQL query, like this:
SELECT ...
FROM ...
WHERE FIELD LIKE N'%ב%'
which works fine. but if I insert more characters, it doesn't return anything even it should (the field contains 'בוצע')
SELECT ...
FROM ...
WHERE FIELD LIKE N'%בו%'
And ideas? thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为绝对 last-restort 选项:如果您需要在Unicode-unsafe端到端方案中插入Unicode文本(即某物 in键盘之间目标数据库是处理正确的Unicode编码,或使用其他编码),那么您应该始终能够倒下来使用
concat(nchar(),...)
仅使用 7-bit ascii-safe t-sql source .. 。href =“ https://learn.microsoft.com/en-us/sql/t-sql/functions/nchar-transact-sql?view=sql-sql-server-ver16” nchar()函数 - 无论您如何保存或编码SQL rtl/ltr处理也...):(
由于某种原因,我似乎无法将希伯来文字发布到stackoverflow的情况下,而无需rtl/ltr弄乱 - 所以这是我使用linqpad所获得的char值的屏幕截图):
As an absolute last-resort option: if you need to insert Unicode text in a Unicode-unsafe end-to-end scenario (i.e. where something in-between your keyboard and the target database is mangling correct Unicode encoding, or using some other encoding) then you should always be able to fall-back to using
CONCAT( NCHAR(), ... )
to build a string using only 7-bit ASCII-safe T-SQL source...You'd replace the literal Hebrew characters in the string-literal with an
NCHAR()
function - this will work regardless of how your SQL is saved or encoded (don't forget RTL/LTR handling too...):(For some reason I can't seem to post Hebrew text to StackOverflow without RTL/LTR getting messed-up - so here's a screenshot of the char values I got using Linqpad):
请检查以下内容。
SQL
Please check the following.
SQL