原作在sql 2000中有一些問題。修正錯誤並在sql 2000中執行通過。
set nocount on
select @v_lowerstr = ltrim(rtrim(str(@n_lowermoney,20,2))) --四捨五入為指定的精度並刪除資料左右空格
select @i_i = 1
select @v_upperstr = ''
while ( @i_i <= len(@v_lowerstr))
begin
select @v_upperpart = case substring(@v_lowerstr,len(@v_lowerstr) - @i_i + 1,1)
when '.' then '元'
when '0' then '零'
when '1' then '壹'
when '2' then '貳'
when '3' then '叄'
when '4' then '肆'
when '5' then '伍'
when '6' then '陸'
when '7' then '柒'
when '8' then '捌'
when '9' then '玖'
end+
case @i_i
when 1 then '分'
when 2 then '角'
when 3 then ''
when 4 then ''
when 5 then '拾'
when 6 then '佰'
when 7 then '仟'
when 8 then '萬'
when 9 then '拾'
when 10 then '佰'
when 11 then '仟'
when 12 then '億'
when 13 then '拾'
when 14 then '佰'
when 15 then '仟'
when 16 then '萬'
else ''
endselect @v_upperstr = @v_upperpart + @v_upperstr
select @i_i = @i_i + 1
end--------print '//v_upperstr ='+@v_upperstr +'//'
if ( @v_transtype=0 )
begin
select @v_upperstr = replace(@v_upperstr,'零拾','零')
select @v_upperstr = replace(@v_upperstr,'零佰','零')
select @v_upperstr = replace(@v_upperstr,'零仟','零')
select @v_upperstr = replace(@v_upperstr,'零零零','零')
select @v_upperstr = replace(@v_upperstr,'零零','零')
select @v_upperstr = replace(@v_upperstr,'零角零分','整')
select @v_upperstr = replace(@v_upperstr,'零分','整')
select @v_upperstr = replace(@v_upperstr,'零角','零')
select @v_upperstr = replace(@v_upperstr,'零億零萬零元','億元')
select @v_upperstr = replace(@v_upperstr,'億零萬零元','億元')
select @v_upperstr = replace(@v_upperstr,'零億零萬','億')
select @v_upperstr = replace(@v_upperstr,'零萬零元','萬元')
select @v_upperstr = replace(@v_upperstr,'萬零元','萬元')
select @v_upperstr = replace(@v_upperstr,'零億','億')
select @v_upperstr = replace(@v_upperstr,'零萬','萬')
select @v_upperstr = replace(@v_upperstr,'零元','元')
select @v_upperstr = replace(@v_upperstr,'零零','零')
end-- 對壹元以下的金額的處理
if ( substring(@v_upperstr,1,1)='元' )
begin
select @v_upperstr = substring(@v_upperstr,2,(len(@v_upperstr) - 1))
endif (substring(@v_upperstr,1,1)= '零')
begin
select @v_upperstr = substring(@v_upperstr,2,(len(@v_upperstr) - 1))
endif (substring(@v_upperstr,1,1)='角')
begin
select @v_upperstr = substring(@v_upperstr,2,(len(@v_upperstr) - 1))
endif ( substring(@v_upperstr,1,1)='分')
begin
select @v_upperstr = substring(@v_upperstr,2,(len(@v_upperstr) - 1))
endif (substring(@v_upperstr,1,1)='整')
begin
select @v_upperstr = '零元整'
endselect @ret=@v_upperstr
go呼叫過程:
declare @ret varchar(200)
exec l2u 567983.897,1,@ret output
select @ret
小寫金額轉換成大寫 sql server
if exists select from dbo.sysobjects where id object id n dbo l2u andxtype in n fn n if n tf drop function dbo l2u go create function dbo.l2u n lowerm...
小寫金額轉換成大寫 sql server
if exists select from dbo.sysobjects where id object id n dbo l2u andxtype in n fn n if n tf drop function dbo l2u go create function dbo.l2u n lowerm...
Java將小寫金額轉換成大寫
工作中遇到金額小寫轉大寫的需求。由於現成的工具包沒有找到此功能。最後搜到 如下 public class test public static string change double v long l math.round v 100 if l 0 string strvalue l i用來控制數...