Hi, I'm trying to remove spaces and html tags from a text field. The functions work great when I test them on data I created but when I go to use them on the field where html data is pulled into they don't work. I can't get this function to remove the spaces. In return this function does not remove the spaces.
EX. @desc = <br> <br> This is a test <html>
Function:
CREATE FUNCTION dbo.fnremovespace (@desc varchar(4000))
RETURNS varchar(4000)
BEGIN
while charindex('>',@desc)>0 and substring(@desc,charindex('>',@desc)+1,1) = ' '
begin
set @desc = stuff(@desc,charindex('>',@desc)+1,1,'')
end
return(@desc)
end
This function should return:
<br><br>This is a test<html>
EX. @desc = <br> <br> This is a test <html>
Function:
CREATE FUNCTION dbo.fnremovespace (@desc varchar(4000))
RETURNS varchar(4000)
BEGIN
while charindex('>',@desc)>0 and substring(@desc,charindex('>',@desc)+1,1) = ' '
begin
set @desc = stuff(@desc,charindex('>',@desc)+1,1,'')
end
return(@desc)
end
This function should return:
<br><br>This is a test<html>