CREATE FUNCTION ChangeBigSmall
(@ChangeMoney money)
RETURNS VarChar(100) AS
BEGIN
Declare @String1 char(20)
Declare @String2 char(30)
Declare @String4 Varchar(100)
Declare @String3 Varchar(100) --The value taken from the original A value
Declare @i int --Loop variable
Declare @J Int --The value of A multiplied by 100 The string length
Declare @Ch1 Varchar(100) --Chinese pronunciation of numbers
Declare @Ch2 Varchar(100) --Chinese pronunciation of digits
Declare @Zero Int --Used Calculate how many zeros there are in a row
Declare @ReturnValue VarChar(100)
Select @ReturnValue = ''
Select @String1 = 'Zero one two three four five Lu Qi 捌玖'
Select @String2 = 'Millions of cents'
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 @Ch1 = Substring(@String1, Cast(@String3 as Int) 1, 1)
Select @Ch2 = Substring (@String2, @i, 1)
Select @Zero = 0 --Indicates that the bit is not zero
end
else Begin
If (@Zero = 0) Or (@i = @J - 9) Or (@i = @J - 5) Or (@i = @J - 1)
Select @Ch1 = 'zero'
Else
Select @Ch1 = ''
Select @Zero = @Zero 1 --Indicates that the base is 0
--If the converted value needs to be expanded, then the value of the following expression I needs to be changed.
Select @Ch2 = ''
If @i = @J - 10 Begin
Select @Ch2 = 'Billion'
Select @Zero = 0
end
If @i = @J - 6 Begin