Tuesday, March 06, 2012

Using PATINDEX in SQL Server

Returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types.

e.g. SELECT PATINDEX('%:%','22:30') will return 3 as the colon appears in that position.

Quite handy to figure out whether a pattern appears in the expression or not.

No comments:

Post a Comment