String update in SQL Server
- by Thiyaneshwaran S
Currently I have varchar field. The delimiter is "$P$P$".
The delimiter will appear at least once and at most twice in the varchar data.
Eg.
Sample Heading$P$P$Sample description$P$P$Sample conclusion
Sample Heading$P$P$Sample Description
If the delimiter appears twice, I need to insert a text before the second occurance of the delimiter.
Eg:
Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion
If the delimiter occurs only once, then I need to insert a text at the end of the field.
Eg:
Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE
How this can be done in SQL query?