Saturday, January 27, 2007

TSQL Function : fn_SqueezeSpaces

This function reduces Multiple Spaces to a single instance.
Good for cleaning up text -

CREATE FUNCTION [dbo].[fn_SqueezeSpaces] (@String varchar(8000)) 
RETURNS VARCHAR(8000) 
AS 
BEGIN 
RETURN REPLACE(REPLACE(REPLACE(@String,' ',' '),' ',''),'','')
END

No comments: