Click here to Skip to main content
15,908,931 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have string ', 11, 22,aa, cc, dd, 77 '


i will pass this string to this function as 1st parameter 2nd parameter would be the position on which i want to insert or add comma or number or alphanumeric character between string.

example ' a, b , c , d ,e ,1 ' is string

Fucntioninsertstring ( ' a, b , c , d ,e ,1 ' , 3, F )

out put would be ' a, b , F c , d ,e ,1 '



What I have tried:

i have create function getting all the values passing in string.

but dynamically if i want check send position at which i want to insert any character.

and output will be updated string.
Posted
Updated 10-Aug-18 21:19pm

1 solution

Basically, you are doing the wrong thing.
Don't store CSV data in a single column, it becomes a nightmare to work with, partly because SQL string handling is ... um ... poor*, but mostly because it;s the wrong way to do it.
When you store CSV data, you prevent SQL from doing what it does best: understanding and manipulating the relationships between data - all you gain is a small amount of "easy insert" ability in your presentation language code.
Instead of doing that, set up a separate table to hold each CSV item separately, with a foreign key back to the original table row. That way, insert, remove, search; they all become a whole load simpler, and the original INSERT, UPDATE, and SELECT operations become only slightly more complex.


* He said, politely
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900