string update in sqlserver

Posted by Thiyaneshwaran S on Stack Overflow See other posts from Stack Overflow or by Thiyaneshwaran S
Published on 2010-06-09T18:15:36Z Indexed on 2010/06/09 18:22 UTC
Read the original article Hit count: 134

Currently i have varchar field. The delimiter is "$P$P$". The delimiter will appear atleast once and atmost 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?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server