Handle Square brackets [] in Search

Posted on 2005-03-16
Medium Priority
Last Modified: 2010-05-18
Data in column --- "ABC [B]"

Select * from TBL where dataField like '%ABC%'  -- I get an exact match
Select * from TBL where dataField like '%ABC [B]%'  -- No match

How do I handle Square brackets for my search?

Question by:vbothello
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
LVL 34

Accepted Solution

Brian Crowe earned 600 total points
ID: 13559322
Select * from TBL where dataField like '%ABC /[B/]%'  ESCAPE '/'
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 400 total points
ID: 13559348
Use an "ESCAPE" character to "tell" SQL to treat the next character literally:

SELECT * from TBL where dataField like '%ABC $[B$]%' ESCAPE '$'


Expert Comment

ID: 13559384
or use
SELECT * from TBL where dataField like '%ABC [[]B]%'

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

762 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