Search code examples
sql-serverstringt-sqlsql-function

Add character after specific character in sql server


I have a string and need to add character ',' after each character'}' and the string doesn't have fixed length

and need to add '[' in the start of text and ']' in the end of text

for example :

enter image description here


Solution

  • We can use REPLACE() here along with a concatenation:

    UPDATE yourTable
    SET val = '[' + REPLACE(val, '}{', '},{') + ']';