Difference between CHARINDEX and PATINDEX

udayarumilli_charindexDifference between CHARINDEX and PATINDEX

CHARINDEX: It is a string function which returns the starting position of a pattern.

PATINDEX: It is a string function which returns the starting position of a pattern. We can also use wildcard characters in searching for a pattern.

Let’s see some examples to understand the exact difference

First create a table and insert some test data.

Let’s try these examples with the column “Activity” column

Now let’s try the same with the column “Log_Desc”

Briefly PATINDEX = CHARINDEX + Wildcard Search

Posted in SQL Development | Tagged , , , , , , , , | Leave a comment

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz