dbWriter SQL parse leading character function.
Remove any number of leading characters from a field:
CREATE FUNCTION dbo.ParseChar
(
@string VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @IncorrectCharLoc INT
DECLARE @theChar char-- set @theChar to the leading
character you want removed.
SET @theChar = '0'
SET @IncorrectCharLoc = PATINDEX(@theChar +'%', @string)
WHILE @IncorrectCharLoc > 0
BEGIN
SET @string = STUFF(@string, @IncorrectCharLoc, 1, '')
SET @IncorrectCharLoc = PATINDEX('0%', @string)
END
SET @string = @string
RETURN @string
END
|
|