Why does T-SQL SELECT WHERE (DATA LIKE '_2_%') retrieve DATA = '_244_1' ?

The T-SQL statement
SELECT  [DATA]
  FROM DATABASE
WHERE (DATA LIKE '_2_%')

Retrieves values like _244_1 , _26_1 and _268_1.

Shouldn't it only pick up values like _2_1 and _2_abc ?

Thank you,
LVL 1
RichardKlineAsked:
Who is Participating?
 
Ephraim WangoyaCommented:

An underscore means any single character

 _2_  could be 123
0
 
Ephraim WangoyaCommented:
For your case try

WHERE (DATA LIKE '[_]2[_]%')
0
 
RichardKlineAuthor Commented:
Gosh, do I feel silly.

Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.