SQL Amount lowercase to uppercase

Source: Internet
Author: User

CREATE FUNCTION dbo. L2U (@n_LowerMoney Numeric (15,2), @v_TransType int) RETURNS varchar ($) as BEGIN Declare @v_LowerStr varchar (200)-Lowercase amount D Eclare @v_UpperPart varchar (Declare @v_UpperStr varchar (200)--capitalization Declare @i_I intset @v_LowerStr = LTRIM (RTRIM (ROU ND (@n_LowerMoney, 2))--rounded to the specified precision and delete the data left and right space set @i_I = 1set @v_UpperStr = "while (@i_I <= len (@v_LowerStr)) Beginselec T @v_UpperPart = case substring (@v_LowerStr, Len (@v_LowerStr)-@i_I + All) when '. ' Then ' $ ' when ' 0 ' and ' 0 ' when ' 1 ' then ' one ' when ' 2 ' then ' if ' 3 ' then ' if ' 4 ' then ' if ' 5 ' then ' if ' 6 ' then ' N ' when ' 7 ' then ' seven ' when ' 8 ' then ' BA ' when ' 9 ' then ' JIU ' end+ case @i_IWHEN 1 Then ' minute ' when 2 Then ' Corner ' when 3 then ' when 4 T HEN ' When the 5 then ' pick ' when the 6 then ' "When the 7 Then '" When the 8 Then ' "When the 9 then ' pick ' when" then ' hundred ' when the then ' thousand ' when HEN ' When the then ' pick ' when the "when" when the then ' hundred ' when the then ' million ' and ' ELSE ' endset @v_UpperStr = @v_UpperPart + @v_Upper Strset @i_I = @i_I + 1endif (0 = @v_TransTyPE) Beginset @v_UpperStr = replace (@v_UpperStr, ' 0 pickup ', ' 0 ') Set @v_UpperStr = replace (@v_UpperStr, ' 0 bai ', ' 0 ') set @v_UpperStr = Replace (@v_UpperStr, ' 0 thousand ', ' 0 ') Set @v_UpperStr = replace (@v_UpperStr, ' 000 ', ' 0 ') Set @v_UpperStr = replace (@v_UpperStr, ' 00 ', ' 0 ') Set @v_UpperStr = replace (@v_UpperStr, ' Certer ', ' whole ') set @v_UpperStr = replace (@v_UpperStr, ' 0 ', ' whole ') set @v_ UPPERSTR = replace (@v_UpperStr, ' 0 angle ', ' 0 ') Set @v_UpperStr = replace (@v_UpperStr, ' 0 ', ' billion ') set @v_UpperStr = replace ( @v_UpperStr, ' billion zero million ', ' billion Yuan ') Set @v_UpperStr = replace (@v_UpperStr, ' 0 ', ' billion ') set @v_UpperStr = replace (@v_UpperStr, ' 0 Yuan ', ' million ') set @v_UpperStr = replace (@v_UpperStr, ' zero Yuan ', ' million ') set @v_UpperStr = replace (@v_UpperStr, ' 0 ', ' billion ') set @v_ UPPERSTR = replace (@v_UpperStr, ' 0 ', ' million ') set @v_UpperStr = replace (@v_UpperStr, ' $0 ', ' meta ') set @v_UpperStr = replace (@v_ Upperstr, ' 00 ', ' 0 ') end--the amount below one dollar if (' meta ' = substring (@v_UpperStr)) Beginset @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)) endif (' 0 ' = substring (@v_UpperStr, +)) BegiNset @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)) endif (' angle ' = substring (@v_UpperStr)) Beginset @v_ UPPERSTR = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)) endif (' min ' = substring (@v_UpperStr,)) Beginset @v_UpperStr = substring (@v_UpperStr, 2, (Len (@v_UpperStr)-1)) endif (' whole ' = substring (@v_UpperStr,)) beginset @v_UpperStr = ' 0 Yuan Whole ' endreturn @v_UpperStrENDGO--select dbo. L2U (0,1), dbo. L2U (010.1,0)

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.