Thursday, March 22, 2012

Escape sequence

Hi,
I have a question with this query -
SELECT * FROM table1 WHERE column1 = 'T_C_%';

This query returns rows where column1 = "T_Care", "T_CRP" etc etc, whereas I was expecting only rows where column1 = "T_C_Tail", "T_C_Head"

However, when I use an escape character(/), the results are more in the lines of the expected results.

Can somebody explain this?
cheers/- PradeepIn a LIKE expression, any underscore (_) matches any one character, and any percent sign (%) matches any group of characters. You can also use brackets ([]) to define sets of characters.

See the BOL description of LIKE (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_la-lz_115x.asp) for more details.

-PatP|||Thanks Pat, really appreciate your quick response.
-Pradeepsql

No comments:

Post a Comment