Skip to content
Advertisement

I am new to SQL Server. I created a function which action like charindex

I am new to SQL server. I am trying to create a scalar-valued function which will act like charindex.

but I am not so sure why when I call the function like

it return 0 as result. Thank you so much for your help 🙂 have a great day guys

Advertisement

Answer

In SQL Server, you need to specify lengths on string datatypes. If you don’t, it assumes length 1.

Therefore your create function line should look like

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement