This user defined function removes leading zeros in a given string.
CREATE FUNCTION [dbo].[fnRemoveLeadingZero](@value varchar(255))
returns varchar(255)
as
begin
declare @trimcount int
select @trimcount = PATINDEX ('%[^0]%', @value)
SELECT @value = Substring(@value, @trimcount,len(@value))
return @value
end
returns varchar(255)
as
begin
declare @trimcount int
select @trimcount = PATINDEX ('%[^0]%', @value)
SELECT @value = Substring(@value, @trimcount,len(@value))
return @value
end
No comments:
Post a Comment