--THIS SCRIPT WILL TAKE A STRING AND RETURN WITH ALL OF THE SPACES REMOVED CREATE FUNCTION dbo.fn_StripSpaces ( @tString varchar(255) ) RETURNS varchar(255) AS /* Art McCabe Function that will take a string as a parameter and return that string with all of the spaces removed. This can be used anywhere you have a need to remove all spaces not just trailing or leading spaces. Use : dbo.dbo.fn_StripSpaces(' More stuff ') Return : 'Morestuff' */ BEGIN DECLARE @retVal varchar(255) SET @retVal = REPLACE( REPLACE( REPLACE(@tString, SPACE(1), '<>') ,'><', SPACE(0)) ,'<>', SPACE(0)); RETURN @retVal END next2none is what others feel about the maverick
Why should that be in a UDF? -- Frank Kalis Microsoft SQL Server MVP Webmaster:http://www.insidesql.de Heute schon gebloggt?http://www.insidesql.de/blogs
Btw, quote: Art McCabe if that is the original author of the script, please follow this forum's policy: quote: If you have written an original script that you think may be of use to other SQL Server DBAS or developers, please post them here. Please only post original scripts, not scripts you have found elsewhere. -- Frank Kalis Microsoft SQL Server MVP Webmaster:http://www.insidesql.de Heute schon gebloggt?http://www.insidesql.de/blogs