Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with brackets

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Hello,
my problem is that i have in my table string fields containing brackets inside exp: arr[1].
Whenever i use a Select query with a
WHERE FIELD LIKE 'arr[1]'
i get no result.
I know the problem is coming from Brackets but what should be done in order to get the right results from the query.
Thanks
 
Hiya,

The problem is that SQL uses square brackets as a wildcard in queries, so you could look for numbers between 071 and 074 by doing

WHERE field LIKE '07[1-4]%'

What you need to do for a literal search using any wildcard is to use = not like

so, you need WHERE FIELD= 'arr[1]'

HTH

Tim
 

You can search for left brackets by enclosing them in brackets. Otherwise, SQL Server treats brackets as ESCAPE characters.

Select * from table
where field like 'arr[[]1]%'

You can also designate a different ESCAPE character.

Select * from #t
where field like 'arr/[1]%' ESCAPE '/' Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top