The amount of the arabic digital converted into Chinese stored procedures

xiaoxiao2021-03-06  99

Create Procedure Atoc @changemoney Money As Set NoCount on Declare @ String1 Char (20) Declare @ String2 Char (30) Declare @ string4 varchar (100) DECLARE @ String3 Varchar (100) - Value from the original a value Declare @ I int - cyclic variable declare @j int --a multiply by 100 string length DECLARE @ ch1 varchar (100) - Digital Chinese Reading Declare @ ch2 varchar (100) - Digital Bit Han Character Read Method Declare @zero int - used to calculate a few zero declare @ReturnValue varchar (100) select @RETURNVALUE = '' SELECT @ String1 = 'zero 壹 贰 柒捌' SELECT @ String2 = '佰 佰 万 佰 佰 佰 元 分 'SELECT @ String4 = Cast (@ ChangeMoney * 100 as int) SELECT @ J = LEN (Cast ((@ ChangeMoney * 100) as int)) Select @ string2 = Right (@ string2, @ j) SELECT @i = 1 while @i <= @J begin select @ String3 = substring (@ string4, @ i, 1) if @ String3 <> '0' begin select @ cha1 = substring @ String1, Cast (@ String3 AS INT) 1, 1) Select @ cha2 = substring (@ string2, @i, 1) select @zero = 0 - means that the bib is not zero ELSE BEGIN IF (@zero = 0) or (@i = @J - 9) or (@i = @J - 5) OR (@i = @J - 1) SELECT @ CH1 = 'zero' else select @ cha1 = '' select @zero = @zero

1 - indicates that the bibl is 0 - if the value of the conversion needs to be expanded, the value of the following expression i is required.

SELECT CH2 = '' IF @i = @J - 10 Begin Select @ CH2 = 'billion' SELECT @zero = 0 end if @i = @J - 6 Begin select @ CH2 = 'Wan' SELECT @zero = 0 End IF @i = @J - 2 Begin Select @ CH2 = 'yuan' select @zero = 0 end if @i = @J select @ CH2 = 'whole' end select @RETURNVALUE = @RETURNVALUE @ ch1 @ cha2 select @i = @ i 1 End - Finally, the extra zero will remove the IF charIndex ('", @ returnvalue) <> 0 select @ReturnValue = Replace (@ReturnValue,' 仟", '仟') if charIndex (')佰 ', @ returnvalue <> 0 select @ReturnValue = Replace (@ReturnValue,' 佰 佰 ',' ') if charIndex (' zero ", @ ReturnValue) <> 0 select @ReturnValue = Replace (@ReturnValue , 'Zero yuan', 'yuan') If Charindex ('万', @ ReturnValue) <> 0 select @ReturnValue = Replace (@ReturnValue, '万', '万') if Charindex ('零', @ ReturnValue) <> 0 select @returnValue = Replace (@ReturnValue, '零', 'billion') if Charindex ('zero ", @ ReturnValue <> 0 select @

转载请注明原文地址:https://www.9cbs.com/read-124103.html

New Post(0)