I wanted to know if in SQL Server there is an equivalent to the Oracle INSTR function?
I know that there is CHARINDEX and PATINDEX, but with the Oracle version I can also specify the Nth appearance of the character(s) I am looking for.
Oracle
INSTR:instr( string1, string2 [, start_position [, **nth_appearance** ] ] )
The CHARINDEX almost gets me there, but I wanted to have it start at the nth_appearance of the character in the string.
You were spot on that
nth_appearancedoes not exist in SQL Server.Shamelessly copying a function (Equivalent of Oracle’s INSTR with 4 parameters in SQL Server) created for your problem (please note that @Occurs is not used the same way as in Oracle – you can’t specify “3rd appearance”, but “occurs 3 times”):