Remove All Spaces - Function

CREATE FUNCTION [dbo].[ufn_utl_RemoveAllSpaces]
(
    @InputStr VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
    DECLARE @ResultStr VARCHAR(8000);
    SET @ResultStr = @InputStr;
    WHILE CHARINDEX(' ', @ResultStr) > 0
    SET @ResultStr = REPLACE(@InputStr, ' ', '');

    RETURN @ResultStr;
END;
GO


Comments

Popular posts from this blog

Calculating Age of the person in T-SQL

How to Troubleshoot Subscription issue in Reporting Services

MDX Queries - Current Day - Month and Year