Solved

Escape ~ character for use in tsql contains() function

Posted on 2009-03-29
3
1,067 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
  • 2
3 Comments
 
LVL 11

Assisted Solution

by:mildurait
mildurait earned 20 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query group by data in SQL Server - cursor? 3 29
insert wont work in SQL 14 19
Tsql query 6 20
Sql server get data from a usp to use in a usp 5 15
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

774 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