lowercase capitalization amount [SQL SERVER]

Source: Internet
Author: User
Tags lowercase min
Server| Capital | amount | lowercase
There are some problems with the original in SQL 2000. Fix the error and run it through in SQL 2000.

/********************************************************
Author: (wleii165@yahoo.com)
Version: 1.0
Date Created: 20020227
Modified time:
Features: Lowercase amounts are converted to uppercase
Parameters: N_lowermoney Lowercase Amount
V_transtype species--1:directly translate, 0:read it in words
Output: Uppercase Amount
********************************************************/
CREATE PROCEDURE dbo. L2u
(
@n_LowerMoney Numeric (15,2),
@v_TransType int,
@RET VARCHAR (MB) output
)
As

Declare @v_LowerStr VARCHAR (200)--Lowercase amount
Declare @v_UpperPart VARCHAR (200)
Declare @v_UpperStr VARCHAR (200)--Capital amount
Declare @i_I int

SET NOCOUNT ON

Select @v_LowerStr = LTRIM (RTRIM (STR (@n_LowerMoney, 20,2))--rounded to the specified precision and delete the left and right spaces

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 ' Yuan '
When ' 0 ' THEN ' 0 '
When ' 1 ' THEN '
When ' 2 ' THEN '
When ' 3 ' THEN ' three '
When ' 4 ' THEN ' Restaurant '
When ' 5 ' THEN ' Wu '
When ' 6 ' THEN ' land '
When ' 7 ' THEN ' qi '
When ' 8 ' THEN ' BA '
When ' 9 ' THEN ' nine '
End
+
Case @i_I
When 1 THEN ' min '
When 2 THEN ' Corner '
When 3 THEN '
When 4 THEN '
When 5 THEN ' pick '
When 6 THEN ' Bai '
When 7 THEN ' thousand '
When 8 THEN ' million '
When 9 THEN ' pick '
When ten THEN ' Bai '
When one THEN ' thousand '
When THEN ' billion '
When THEN ' picks '
When THEN ' Bai '
When THEN ' thousand '
When THEN ' million '
ELSE ' "
End
Select @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, ' 0 Pick ', ' 0 ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 bai ', ' 0 ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 ', ' 0 ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 000 ', ' 0 ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 00 ', ' 0 ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' Certer ', ' whole ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 points ', ' whole ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 corners ', ' 0 ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 yuan ', ' billion ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' billion zero million ', ' billion ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 ', ' billion ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 yuan ', ' million ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' million Zero ', ' million ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 ', ' billion ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 ', ' million ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 0 yuan ', ' yuan ')
Select @v_UpperStr = REPLACE (@v_UpperStr, ' 00 ', ' 0 ')
End

--the treatment of the amount below one yuan
if (substring (@v_UpperStr, 1, 1) = ' Yuan ')
Begin
Select @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)
End

if (substring (@v_UpperStr, 1, 1) = ' 0 ')
Begin
Select @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)
End

if (substring (@v_UpperStr, 1, 1) = ' Corner ')
Begin
Select @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)
End

if (substring (@v_UpperStr, 1, 1) = ' min ')
Begin
Select @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)
End

if (substring (@v_UpperStr, 1, 1) = ' whole ')
Begin
Select @v_UpperStr = ' 0 yuan int '
End

Select @ret = @v_UpperStr

Go

Call Procedure:

DECLARE @ret varchar (200)

exec l2u 567983.897,1, @ret output

Select @ret


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.