金額小寫轉大寫

2021-09-09 02:49:39 字數 4422 閱讀 1291

create

procedure

[dbo].

[trannumbertobigfordecrypt](

@n_lowermoney

numeric(15,

2),@v_transtype

int,

@ret

varchar

(200

) output)--

with encryption

as/*

*********************************

descript:解密exec sp_decrypt 'trannumbertobig'

*/declare

@v_lowerstr

varchar

(200

) --

小寫金額 

declare

@v_upperpart

varchar

(200

) declare

@v_upperstr

varchar

(200

) --

大寫金額

declare

@startstr

varchar(30

) --

點號前面的部分

declare

@endstr

varchar(30

) --

點號後面部分

declare

@i_i

int,

@idx

int,

@e_i

int,

@iint

declare

@end_upper

varchar

(100

),@end_part

varchar

(100

)select

@v_lowerstr

=ltrim

(rtrim

(convert

(varchar(30

),@n_lowermoney

))) 

--變成字串並刪除資料左右空格

--if(charindex('.',@v_lowerstr)>0)

begin

set@idx

=charindex('

.',@v_lowerstr

)set

@startstr

=substring

(@v_lowerstr,1

,@idx-1

)--print @v_lowerstr

select

@i_i=1

select

@v_upperstr=''

while

( @i_i

<=

len(

@startstr

))begin

select

@v_upperpart

=case

substring

(@startstr

,len

(@startstr) -

@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'萬

'else

''end

select

@v_upperstr

=@v_upperpart

+@v_upperstr

select

@i_i

=@i_i+1

end--

if ( @v_transtype=0 )

--begin

--print @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,'

零零',''

)--endselect

@endstr

=ltrim

(rtrim

(substring

(@v_lowerstr

,@idx

,len

(@v_lowerstr)-

@idx+1

)))select

@e_i=1

select

@end_part=''

select

@end_upper=''

while

(@e_i

<=

len(

@endstr

))begin

select

@end_part

=case

substring

(@endstr

,@e_i,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

select

@end_upper

=@end_upper

+@end_part

select

@e_i

=@e_i+1

endset@i=

len(

@end_upper

)while(@i

>0)

beginif(

right

(@end_upper,1

)='零

'orright

(@end_upper,1

)='點

')begin

select

@end_upper

=left

(@end_upper,@i

-1)select@i=

@i-1end

else

break

end--

select @part=@v_upperstr+@end_upper

select

@ret

=@v_upperstr

+@end_upper

endgo

金額小寫轉大寫

create procedure dbo trannumbertobigfordecrypt n lowermoney numeric 15,2 v transtype int,ret varchar 200 output with encryption as descript 解密exec sp ...

ORACLE 小寫金額轉大寫金額

create or replace function money2chinese money in number return varchar2 is stryuan varchar2 150 stryuanfen varchar2 152 numlenyuan number numlenyuanf...

小寫轉大寫金額 SQLSERVER

原作在sql2000中有一些問題。修正錯誤並在sql2000中執行通過。setnocounton select v lowerstr ltrim rtrim str n lowermoney,20,2 四捨五入為指定的精度並刪除資料左右空格 select i i 1 select v upperst...