I have a table with strings containing 0 to many "blanks" consisting of three underscores. In the same table, I'll have a string representing the words I want to go into those spaces separated by a delimiter.
For example: ___! My name is ___. I am ___ to see you! and Hello|PrinceTyke|happy.
I already have a function written in-house that will give me a row for each word in the delimited list as well as the position in the string.
1 | Hello
2 | PrinceTyke
3 | happy
How can I replace my blank-filled string with those words in order and end up with "Hello! My name is PrinceTyke. I am happy to see you!"?
Edit:
I am using SQL Server 2016 and would like to perform this kind of replacement on sets of rows at a time.
I realized that I didn't fully communicate my problem.
In one table, I have both the original string with "blanks" as well as the string of characters I want to do the replacement with.
Id | RelatedId | Text
----------------------------------------------------------
1 | NULL | ___! My name is ___. I am ___ to see you!
2 | 1 | Hello|PrinceTyke|happy
I have another table that I want to store the output of this replacement in.
Id | OtherTableId | TextOutput
------------------------------------------------------------------------
1 | 1 | Hello! My name is PrinceTyke. I am happy to see you!
This is still slightly simplified, but I hope it's more clear.
'@1! My name is @2. I am @3 to see you!. Then there is some hope of handling this.