0

Is there an alternative for the INSTR() function used in Oracle for SQL Server.

I need to use INSTR() with all four parameters,

INSTR(string, substring [, start_position [, nth_appearance ]])

SQL Server has an option for CHARINDEX(), but it does not allow me to mention the 'nth appearance', it only takes 3 parameters

CHARINDEX(substring, string, start)

Is there any way I can get the exact functionality as INSTR()?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Liam
  • 51
  • 7
  • 1
    Does this answer your question? [SQL Server - find nth occurrence in a string](https://stackoverflow.com/questions/8726111/sql-server-find-nth-occurrence-in-a-string) – Thom A Feb 23 '22 at 09:40
  • 1
    Does this answer your question? [Optimize finding the Nth occurrence of character in string](https://stackoverflow.com/questions/38659811/optimize-finding-the-nth-occurrence-of-character-in-string) – Thom A Feb 23 '22 at 09:41
  • 1
    You can create your own function - https://www.sqlines.com/oracle/functions/instr#:~:text=In%20Oracle%2C%20INSTR%20function%20returns,use%20a%20user%2Ddefined%20function. – Ankit Bajpai Feb 23 '22 at 09:54
  • 2
    It would be useful to give an example of the input and output you want, for those not familiar with the exact functionality of Oracle. – IMSoP Feb 23 '22 at 09:59
  • I can work this out if no other option is left. The thing is I am running a kind of for loop .. and in the nth appearance section I want to get the value (for eg @i value which will increment each time the block of code executes). This can be the possible solution though! .. to create a different function! – Liam Feb 23 '22 at 10:05
  • That function in that link would be terrible for performance mind, @AnkitBajpai . I don't recommend it's use. – Thom A Feb 23 '22 at 10:23

0 Answers0