[sql] How do you strip a character out of a column in SQL Server?

How do you remove a value out of a string in SQL Server?

This question is related to sql sql-server

The answer is


This is done using the REPLACE function

To strip out "somestring" from "SomeColumn" in "SomeTable" in the SELECT query:

SELECT REPLACE([SomeColumn],'somestring','') AS [SomeColumn]  FROM [SomeTable]

To update the table and strip out "somestring" from "SomeColumn" in "SomeTable"

UPDATE [SomeTable] SET [SomeColumn] = REPLACE([SomeColumn], 'somestring', '')

Similar questions with sql tag:

Similar questions with sql-server tag: