Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Escape ~ character for use in tsql contains() function

Posted on 2009-03-29
3
Medium Priority
?
1,090 Views
Last Modified: 2012-05-06
Hi,

I'm using SQL server 2000 and I want to search for records that contain the ~ character in the text. Something like this:

select * from tblText where contains(txt, '~')

Apparently that will not work as ~ character is actually the NEAR operator.

How can I escape it? I wouldn't want to use LIKE expresssion as I want to take advantage of contains() and  its full text index.

Thanks a lot.
0
Comment
Question by:Squarenine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Assisted Solution

by:mildurait
mildurait earned 80 total points
ID: 24015276
~ is ascii character 126

Therefore you can use
SELECT * FROM tblText WHERE contains(txt,char(126))
0
 

Accepted Solution

by:
Squarenine earned 0 total points
ID: 24016167
Hi,

Unfortunately, contains(txt,char(126)) causes a syntax error.

I finally went with::

select * from tblText where charindex('~', txt') > 0

and it works great.

Still want to know how to escape ~ in contains function though.

Thanks anyway.
0
 

Author Comment

by:Squarenine
ID: 24016179
ok
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question