create function dbo.t_bh (@str varchar(20)) returns varchar(20) as begin declare @bh varchar(20),@length int,@i int set @length=12-LEN(@str) if LEN(@str)12 begin set @i=0 while @i@length begin set @str='0'+@str set @i=@i+1 end return @str
create function dbo.t_bh (@str varchar(20))
returns varchar(20)
as
begin
declare @bh varchar(20),@length int,@i int
set @length=12-LEN(@str)
if LEN(@str)<12
begin
set @i=0
while @i<@length
begin
set @str='0'+@str
set @i=@i+1
end
return @str
end
else if isnull(@str,0)=0
begin
set @str='000000000000'
return @str
end
else
begin
return @str
end
return @str
end
--select dbo.t_bh('000022')
,美国空间,网站空间,美国服务器