The amount of the arabic digital converted into Chinese stored procedures

xiaoxiao2021-04-06  304

Date: 2005-6-28 14:26:00 Source: Editor: 108 [full screen View full text] 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 - loop variable Declare @j int --a multiply by 100 string length DECLARE @ ch1 varchar (100 ) - Digital Chinese Reading Declare @ CH2 VARCHAR (100) - Digital Bits of Chinese Character Reading Declare @zero Int - Use to calculate several zero Declare @returnValue varchar (100)

Select @ReturnValue = '' SELECT @ String1 = 'zero zizhai 肆 伍 柒捌 柒捌' SELECT @ String2 = 'Wan Yiyi pickup billion 佰 佰 万 佰 佰 元 元 分'

Select @ string4 = cast (@ ChangeMoney * 100 AS INT)

SELECT @ J = LEN (Cast ((@ CAANGEMONEY * 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 @ CH2 = Substring (@ string2, @i, 1) select @zero = 0 - means that the Bit is not zero ELSE BEGIN IF (@zero = 0) or (@i = @J - 5) OR (@i = @J - 1) SELECT @ CH1 = 'zero' else select @ ch1 = ' '

SELECT @zero = @zero 1 - indicates that this 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 = 10 million 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 @ CH2

SELECT @i = @ i 1 End

- Finally, the extra zero will remove if Charindex ('仟 ", @ ReturnValue) <> 0 select @ReturnValue = Replace (@ReturnValue,' 仟", '仟')

If Charindex ('佰', @ returnvalue) <> 0 select @ReturnValue = Replace (@RETURNVALUE, '佰 佰', '')

If Charindex ('Zero Bill', @ ReturnValue) <> 0 Select @ReturnValue = Replace (@RETURNVALUE, 'Zero ",' Yuan ')

If Charindex ('万', @ ReturnValue) <> 0 select @ReturnValue = Replace (@ReturnValue, '万 万', '10)

IF Charindex ('零', @ ReturnValue) <> 0 Select @ReturnValue = Replace (@ReturnValue, '零', 'billion)

If Charindex ('zero ", @ ReturnValue) <> 0 select @ReturnValue = Replace (@ReturnValue,' zero", 'whole'

If Charindex ('zero ", @ returnvalue) <> 0 select @ReturnValue = Replace (@ReturnValue,' zero ',' zero ')

If Charindex ('zero ", @ ReturnValue) <> 0 select @ReturnValue = Replace (@ReturnValue,' zero", 'zero')

If Charindex ('Elect ", @ ReturnValue <> 0 Select @ReturnValue = Replace (@RETURNVALUE,' Element", 'Yuan'

Select @ReturnValue Go

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

New Post(0)