Science, asked by anoopsingh7190, 1 year ago

Difference between patindex and charindex

Answers

Answered by sushma91
0
CHARINDEX and PATINDEX both functions are used to find the position of a specific character(s) in sql server. Then these should be a question that what the difference between these. Here are differences.

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

CHARINDEX cannot be used with text, ntext, andimage data types, but PATINDEX can be used these.

In CHARINDEX function, we can pass 3 parameters. Syntax is below
select CHARINDEX(”, ”,’’). 3rd parameter is optional. If you don’t set value, then it will start from 1.
In PATINDEX, we can pass 2 parameters. Syntax is below
select PATINDEX(”, ”)
Similar questions