• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1655
  • Last Modified:

Handle Square brackets [] in Search

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?

Thanks
0
vbothello
Asked:
vbothello
2 Solutions
 
Brian CroweDatabase AdministratorCommented:
Select * from TBL where dataField like '%ABC /[B/]%'  ESCAPE '/'
0
 
Scott PletcherSenior DBACommented:
Use an "ESCAPE" character to "tell" SQL to treat the next character literally:


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

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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now