Delete fixed string contained in SQL Server Table Column

27 Views Asked by At

I have a table with filed 'myData' of type nvarchar containing sometimes a data ending with the string '|||' that I want to remove. Obviously the data is not fixed, so I can't just use

UPDATE myTable
SET myData = REPLACE(myData, 'oldString', 'newString')

as this would work just for one record (e.g. oldString = '12-feb-17|||' and newString = '12-feb-17')

How can I do it globally?

1

There are 1 best solutions below

0
Gordon Linoff On BEST ANSWER

You can do:

UPDATE myTable
    SET myData = LEFT(myData, LEN(myData) - 3)
    WHERE myDATE LIKE '%|||';