Skip to content
Advertisement

Query on how to replace numerical data from a string/column

I have values in my column as below. Can anyone help me with how to replace any numeric data present in a column or string to blank using SQL Server query?

enter image description here

Below is the column data. How do I replace the numbers to blank and display only underscores.

Advertisement

Answer

You could approach this by counting the number of underscores, and then generating a string containing this number of underscores:

SELECT Column1, REPLICATE('_', LEN(Column1) - LEN(REPLACE(Column1, '_', '')))
FROM yourTable;

screen capture from demo link below

Demo

Advertisement