从SQL表中搜索特殊字符 [英] Search special characters from SQL table

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

问题描述

Text = "World" world " <world <Word> ‘ word’ ‘ word" word’ =1254.25 = 2545.58. 20%

好伙计,

需要从保存在我的数据库中的字符串中搜索一个单词。搜索词包含特殊字符,例如'!@#$%^<>。下面是用于搜索的sql select查询。

I need to search a word from a string which was saved in my db. The searching word contains special characters such as ""'!@#$%^<>. Below is the sql select query used for the search.

select * from TABLE  where TABLE.text like ('%'+ '" World' +'%')

,因此不搜索某些特殊字符。不会从中搜索到双引号,单引号等字符。需要帮助解决这个问题。谢谢:)

as a result some of the special character are not searched. Characters such as double quotation, single quotation are not searched from this. need assistance with solving this problem asap. thank you :)

推荐答案

这些特殊字符是Unicode字符,当在sql server中处理这些字符时,服务器明确地说,你要处理的字符串中可能有一些unicode字符前缀你的字符串 N'String'

These Special characters are Unicode characters, When ever dealing with these characters in sql server you have to tell sql server explicitly that there can be some unicode characters in the strings you are about to manipulate by prefixing your strings with N'String'

在你的case你会写一个像....的查询。

In your case you would write a query something like ....

select * from TABLE  
where TABLE.text like N'%'+ N'" World' + N'%'

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

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