Pages

Monday, November 30, 2009

Charindex Vs Patindex

CharIndex

PatIndex

1

Returns the Starting position of specified Expression in Character String.

Returns the Starting position of First Occurrence of a pattern in Specified Expression, Or Zeros if Pattern is not found.

2

In Charindex you can specify Start location.

In PatIndex you can not specify starting location. It will return you First Occurrence of a pattern

3

SELECT CHARINDEX(‘;’,’KRISHNA;RADHA’)

Output : 8 It will give u position of Semicolon.

Example : SELECT PATINDEX(‘%A%’,’KRISHNA;RADHA’)

Output : 7 It will give u position of First occurrence of A.

0 comments:

Post a Comment