Technical Article

Remove Leading CHAR's, I.E '0045T050' Removes  00

,

CREATE FUNCTION RemoveCharacter
-- Input dimensions in centimeters
   (@CharToRemove Char(1), @StringToModify VarChar(25))
RETURNS VarChar(25) -- Cubic Centimeters.
AS
BEGIN
   
  DECLARe @Count  int
  SET @Count = 0

  DECLARE @Length int

  SET @Length = LEN(@StringToModify)

  WHILE @Count < @Length
    Begin
     
     IF LEFT( @StringToModify,1) = @CharToRemove
       BEGIN
            SET  @StringToModify = SUBSTRING (@StringToModify, 2, LEN(@StringToModify))
            SET  @Count = @Count + 1
     END
     ELSE
        BEGIN
       SET @Count = @Length
       END
      
  
   END
RETURN @StringToModify
END

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating