如何从中删除前导零
number RESULT WOULD BE LIKE THIS
00000.9 .9
A0001.1 A1.1
G0101.3 G101.3
00808.8 808.8
J0000.5 J.5
如何从中删除前导零
number RESULT WOULD BE LIKE THIS
00000.9 .9
A0001.1 A1.1
G0101.3 G101.3
00808.8 808.8
J0000.5 J.5
更改函数编号(@NUMBER VARCHAR(7))
返回 VARCHAR(7) 为
开始
声明 @NUM VARCHAR(1)
声明@NUM1 VARCHAR(7)
SET @NUM= SUBSTRING(@NUMBER,1,1)
IF(@NUM LIKE '[AZ%]')
BEGIN
SET @NUM1=@NUM+''+CAST(CONVERT(FLOAT,SUBSTRING(@NUMBER,2,7),2)AS VARCHAR(7))
END
别的
BEGIN
SET @NUM1=LTRIM(STR(cast(@NUMBER as float),case when len(cast(@NUMBER as float)) > 7 then 7 else len(cast(@NUMBER as float)) end,1))
END
返回@NUM 结束
declare @input varchar(10);
declare @output varchar(10);
set @input = '00000.9';
while ((ISNUMERIC(substring(@input,1,1)) = 0) or (substring(@input,1,1) = '0'))
begin
if substring(@input,1,1) = '0'
begin
set @input = substring(@input,2,len(@input) )
end
else
if ISNUMERIC(substring(@input,1,1)) = 0
begin
set @output = substring(@input,1,1);
set @input = substring(@input,2,len(@input))
end
end
if LEN(@output) > 0
set @input = @output + @input
select @input
@input 是你的输入