Tuesday, 1 September 2015

Difference Between PatIndex and CharIndex


The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. PATINDEX can use wildcard characters, but CHARINDEX cannot.

These functions take two parameters:
·     The pattern whose position you want. With PATINDEX, the pattern is a literal string that can contain wildcard characters. With CHARINDEX, the pattern is a literal string without wildcard characters.

·         A string-valued expression, generally a column name, searched for the specified pattern.

SELECT CHARINDEX('JA','VIJAY')

O/P :- 3

SELECT PATINDEX('%GMAIL%','VIJAYK0286@GMAIL.COM')

O/P :- 12

SELECT PATINDEX('%GM__L%','VIJAYK0286@GMAIL.COM')

O/P :- 12







4 comments:

  1. Very Well Explained. Can you please also tell us Soundex,IsNumeric functions also.

    ReplyDelete
  2. Hello,
    You can a send a mail for set of people.
    You can loop through an SQL statement and perform certain action until end of the table. Thanks for sharing this article. the above article having a valuable information.

    ReplyDelete
  3. This is really very nice blog to read, thanks for sharing wonderful information. keep share content on MSBI Online Training Hyderabad

    ReplyDelete