I have a string like this ' Hello <> world '. I am using below code to remove duplicate space from the string. But it removes <>
from the string.
SELECT ' Hello <> world ' AS Name
INTO #Temp;
SELECT REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(Name)), ' ', '<>'), '><', ''), '<>', ' ') AS CleanName
FROM #Temp;
Is there any alternative?