Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
Performance Tuning
»
Escaping special characters Full text index...
Escaping special characters Full text index search
Rate Topic
Display Mode
Topic Options
Author
Message
jeepee_in
jeepee_in
Posted Wednesday, January 16, 2008 2:22 PM
Forum Newbie
Group: General Forum Members
Last Login: Friday, May 16, 2008 9:44 AM
Points: 1,
Visits: 9
I have created a full text index on a column of a table. The issue is i need to search for AT&T.
the query i use for search is
SELECT * FROM TABLE_NAME WHERE CONTAINS(COLUMN_NAME, '"AT&T*"')
It returns many records but doesn't return the records with AT&T in it. I guess '&' is killing it, but i have no idea how to escape it in case of full text index search.
Any help will be deeply appreciated.
Post #444012
dimitris.staikos
dimitris.staikos
Posted Sunday, July 08, 2012 4:51 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, October 24, 2012 11:28 AM
Points: 8,
Visits: 43
The '*' is killing you. Use '%' instead.
If you want to search for text that for example contains % or other special characters you have to escape them.
See the example below:
SELECT * FROM
(
SELECT UserName + '&%' + Email AS A FROM Employees
) G
WHERE G.A LIKE '%s&!%x%' ESCAPE '!'
I am concatenating two fields adding &% in between. No escaping needed there.
And I want to look for any record that has the literal pattern 's&%x' inside it
So in the LIKE however, I start with an '%s (the equivalent of *), follow with an 's', follow with an '&' (no escaping needed) and then I escape the '%' using any character I like, so I chose '!'. Then follows 'x' and '%' for the rest of the string.
Pretty straightforward right?
Cheers
Dimitris
Post #1326556
Jeff Moden
Jeff Moden
Posted Sunday, July 08, 2012 12:27 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 7:18 AM
Points: 33,112,
Visits: 27,038
dimitris.staikos (7/8/2012)
The '*' is killing you. Use '%' instead.
Keep in mind that this isn't standard T-SQL. It's Full Text Search.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1326600
dimitris.staikos
dimitris.staikos
Posted Wednesday, July 18, 2012 4:52 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, October 24, 2012 11:28 AM
Points: 8,
Visits: 43
Yeah, you are right, thanks
Post #1331356
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.