sqlpostgresqlreplace

Replace first character in SQL


Am trying to replace the first character of a string. I can replace specific characters using replace() function. But not sure how to replace the first character of all strings in a column.

Sample data:

Column1
43449927
13448927
53443457

Expected result after replacing first character with '7':

Column1
73449927
73448927
73443457

Solution

  • Below syntax helped me,

    '7' || substr(column1, 2, length(column1))