|
alter function to_up(@num numeric(14,2))
returns varchar(100)
as
begin
declare @ndata varchar(20), @cdata varchar(100)
declare @nstr varchar(10),@zflag bit,@t varchar(10),@i int
set @ndata=RIGHT(SPACE(14)+CAST(CAST(ABS(@num*100) AS bigint) AS varchar(20)), 14)
set @cdata=''
set @zflag=0; set @i=1
while @i<=14
begin
set @nstr=substring(@ndata,@i,1)
if @nstr<>' '
begin
--digital
set @nstr=SUBSTRING('Zero One Two Three Lu Wu Qiu Jiu Jiu', CAST(@nstr AS int)+1,1)
set @t=SUBSTRING('Thousand and ten million ten thousand and ten thousand and ten thousand round corner points', @i,1)
if @nstr='zero'
begin
if @t in ('100 million', '10 thousand','round')
set @cdata=@cdata+@t
if @zflag=0
set @zflag=1
end
else
begin
if @zflag=1
begin
if @t='round'
set @cdata=@cdata+@t
else
set @cdata=@cdata+'zero'+@nstr+@t
set @zflag=0
end
else
set @cdata=@cdata+@nstr+@t
end
end
set @i=@i+1
end
IF @num<0
SET @cdata='(negative number)'+@cdata
IF @num=0
SET @cdata='zero circle'
IF @nstr='zero'
SET @cdata=@cdata+'integer'
RETURN(@cdata)
end |
|