0

So I have a function that splits a string based on a character provided. For example

person = "sam, 25;tony, 19"

If I use the function(person, ';') it'll return a table

resulting_table = "sam, 25"
                   "tony, 19"

Now I have another table and I wants to insert the index of ',' for each row in it. I am using

insert into dbo.test_table_1(index)  
   select 
       charindex(',', select * from dbo.fn_parse_function(@json_string, ';')); 

It is giving me an error. Can anyone point me in the right direction?

Thanks in advance

1
  • WHAT error?? We really cannot read your screen - nor your mind - you'll have to TELL US! Commented Jul 27, 2015 at 18:23

1 Answer 1

1

You appear to be using SQL Server and you have a table-valued function. Such a function should go in the from clause:

insert into dbo.test_table_1([index])
    select charindex(val, ',')
    from dbo.fn_parse_function(@json_string, ';') p1(val) 

Note that index is a really bad name for a column, because it is clearly a SQL keyword.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.