金額大寫轉換

2022-08-23 13:03:11 字數 4236 閱讀 3002

use

[toy]go

/****** object: storedprocedure [dbo].[l2u] script date: 03/19/2014 13:15:27 *****

*/set ansi_nulls on

goset quoted_identifier on

goalter

procedure

[dbo

].[l2u](

@n_lowermoney numeric(15,2

),@v_transtype

int,

@ret

varchar(200

) output)as

declare

@v_lowerstr

varchar(200) --

小寫金額

declare

@v_upperpart

varchar(200

) declare

@v_upperstr

varchar(200) --

大寫金額

declare

@i_i

intset 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

1then'分

'when

2then'角

'when

3then

''when

4then

''when

5then'拾

'when

6then'佰

'when

7then'仟

'when

8then'萬

'when

9then'拾

'when

10then'佰

'when

11then'仟

'when

12then'億

'when

13then'拾

'when

14then'佰

'when

15then'仟

'when

16then'萬

'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

oracle 金額大寫轉換

function convert money input number number return varchar2 is i pls integer snum varchar2 20 ltrim replace to char abs input number 9999999999999990.9...

Python金額大寫轉換

判斷是否包含小數點,還有判斷是否只包含小數點和數字的這邊沒寫出來 def is contain dot check str check str str check str for ch in check str if ch return true return false def digital t...

小寫金額轉換為大寫金額

我的乙個朋友寫的,金額轉成大寫 public static string convertmoney decimal dnum string str2 new string string strunit string.join str1 string struppernum string.join s...