Question for you: What's the difference between CHARINDEX and PATINDEX?
The difference is not clear to me.
When I run the below script it returns the same values:
Declare @str varchar(100) = 'abcdefghigklmnopqrstuvwxyz_e'
Searches an expression for another expression and returns its starting position if found.
-- Select the first e in a string
SELECT CHARINDEX('ef', @str)
-- Select the first e in a string, starting at the 10th character
SELECT CHARINDEX('e', @str, 10)
Turns 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.
SELECT PATINDEX('%efg%', @str)
They both return bigint's that are the starting values.
Full disclosure: I'm studying for the 70-433 exam, and this is not a work-related question.