Create Function [DBO]. [f_num_chn] (@ num numeric (14,2 ))
Returns varchar (100) with encryption
As
Begin
-- Copyright: pbsql
Declare @ n_data varchar (20), @ c_data varchar (100), @ n_str varchar (10), @ I int
Set @ n_data = right (space (14) + Cast (cast (ABS (@ num * 100) as bigint) as varchar (20), 14)
Set @ c_data =''
Set @ I = 1
While @ I <= 14
Begin
Set @ n_str = substring (@ n_data, @ I, 1)
If @ n_str <>''
Begin
If not (substring (@ n_data, @ I, 2) = '00') or
(@ N_str = '0') and (@ I = 4) or (@ I = 8) or (@ I = 12) or (@ I = 14 ))))
SET @ c_data = @ c_data + SUBSTRING)
IF not (@ n_str = '0') and (@ I <> 4) and (@ I <> 8) and (@ I <> 12 ))
SET @ c_data = @ c_data + SUBSTRING)
If substring (@ c_data, LEN (@ c_data)-1, 2) = 'billionaire'
SET @ c_data = SUBSTRING (@ c_data, 1, LEN (@ c_data)-1)
END
SET @ I = @ I + 1
END
IF @ num <0
SET @ c_data = '(negative number)' + @ c_data
IF @ num = 0
SET @ c_data = 'circle 0'
IF @ n_str = '0'
SET @ c_data = @ c_data + 'Integral'
RETURN (@ c_data)
End
Go
--------------------------------------------------------------
/*************************************** *****************
Author: (birdie_7761@cmmail.com)
Version: 1.0
Creation Time: 20020227
Modification time:
Function: converts the lowercase value to uppercase.
Parameter: n_lowermoney lower-case amount
V_transtype type -- 1: directly translate, 0: Read it in words
Output: capital amount
**************************************** ****************/
If exists (select * From DBO. sysobjects where id = object_id (n' [DBO]. [l2u] ') and xtype in (n'fn', n'if', n'tf '))
Drop function [DBO]. [l2u]
Go
Create Function DBO. l2u (@ n_lowermoney numeric (15,2), @ v_transtype INT)
Returns varchar (200)
Begin
Declare @ v_lowerstr varchar (200) -- lower case amount
Declare @ v_UpperPart VARCHAR (200)
Declare @ v_UpperStr VARCHAR (200) -- Capital Amount
Declare @ I _ I int
Set @ v_LowerStr = LTRIM (RTRIM (ROUND (@ n_LowerMoney, 2) -- returns the specified precision and deletes the Left and Right spaces of the data.
Set @ I _ I = 1
Set @ 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 'yi'
WHEN '2' THEN 'er'
WHEN '3' THEN 'san'
WHEN '4' then'
WHEN '5' then' Wu'
WHEN '6' THEN 'l'
WHEN '7' then' THEN'
WHEN '8' then' THEN'
WHEN '9' then' THEN'
END
+
Case @ I _ I
WHEN 1 THEN 'Min'
WHEN 2 THEN 'angular'
When 3 then''
When 4 then''
When 5 then 'start'
When 6 then 'hangzhou'
When 7 then 'hangzhou'
When 8 then 'wane'
When 9 then 'start'
When 10 then 'hangzhou'
When 11 then 'hangzhou'
When 12 then '100'
When 13 then 'start'
When 14 then 'hangzhou'
When 15 then 'hangzhou'
When 16 then 'wane'
Else''
End
Set @ v_upperstr = @ v_upperpart + @ v_upperstr
Set @ I _ I = @ I _ I + 1
End
If (0 = @ v_transtype)
Begin
Set @ v_upperstr = Replace (@ v_upperstr, 'zero', '0 ')
Set @ v_upperstr = Replace (@ v_upperstr, 'zero failed', '0 ')
Set @ v_upperstr = Replace (@ v_upperstr, 'zero failed', '0 ')
Set @ v_upperstr = Replace (@ v_upperstr, 'zero zero 0', 'zero ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, 'zero angle and zero point', 'Integral ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, 'zero point', 'Integral ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '100, 0 billion, 0 thousand, RMB ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '100 million RMB 0 thousand ', '100 billion RMB ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '2017 11111100', '100% ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '000000', '000000 ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '10 thousand yuan ', '10 thousand yuan ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '000000', '100 ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '2013', 'wan ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '0 meta', 'meta ')
Set @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
End
-- Processing of less than 1 RMB
If ('meta' = substring (@ v_UpperStr, 1, 1 ))
Begin
Set @ v_UpperStr = substring (@ v_UpperStr, 2, (len (@ v_UpperStr)-1 ))
End
If ('0' = substring (@ v_UpperStr, 1, 1 ))
Begin
Set @ v_UpperStr = substring (@ v_UpperStr, 2, (len (@ v_UpperStr)-1 ))
End
If ('angular '= substring (@ v_UpperStr, 1, 1 ))
Begin
Set @ v_UpperStr = substring (@ v_UpperStr, 2, (len (@ v_UpperStr)-1 ))
End
If ('sub' = substring (@ v_UpperStr ))
Begin
Set @ v_UpperStr = substring (@ v_UpperStr, 2, (len (@ v_UpperStr)-1 ))
End
If ('Integral '= substring (@ v_UpperStr ))
Begin
Set @ v_UpperStr = 'zero yuan integral'
End
Return @ v_UpperStr
END
GO
Select dbo. L2U (12.93, 1), dbo. L2U (12.93, 0)
Bytes -----------------------------------------------------------------------------------
Create procedure dbo. L2U
(
@ N_LowerMoney numeric (15, 2 ),
@ V_TransType int,
@ Ret varchar (200) output
)
AS
Declare @ v_LowerStr VARCHAR (200) -- lower case 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) -- returns the specified precision and deletes the Left and Right spaces of the data.
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 'yi'
WHEN '2' THEN 'er'
WHEN '3' THEN 'san'
WHEN '4' then'
WHEN '5' then' Wu'
WHEN '6' THEN 'l'
WHEN '7' then' THEN'
WHEN '8' then' THEN'
WHEN '9' then' THEN'
END
+
Case @ I _ I
WHEN 1 THEN 'Min'
WHEN 2 THEN 'angular'
WHEN 3 then''
WHEN 4 then''
WHEN 5 THEN 'start'
WHEN 6 THEN 'hangzhou'
WHEN 7 THEN 'hangzhou'
WHEN 8 THEN 'wane'
WHEN 9 THEN 'start'
WHEN 10 THEN 'hangzhou'
WHEN 11 THEN 'hangzhou'
WHEN 12 THEN '100'
WHEN 13 THEN 'start'
WHEN 14 THEN 'hangzhou'
WHEN 15 THEN 'hangzhou'
WHEN 16 THEN 'wane'
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, 'zero', '0 ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, 'zero zero 0', 'zero ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, 'zero-angle and zero-point', 'Integral ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, 'zero point', 'Integral ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '100, 0 billion, 0 thousand, RMB ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '100 million RMB 0 thousand ', '100 billion RMB ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '2017 111111', '100% ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '100 RMB ', '10 RMB ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '10 thousand yuan ', '10 thousand yuan ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '000000', '100 ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '2013', 'wan ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '0 meta', 'meta ')
Select @ v_UpperStr = REPLACE (@ v_UpperStr, '0', '0 ')
End
-- Processing of less than 1 RMB
If (substring (@ v_UpperStr, 1, 1) = 'meta ')
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) = 'angular ')
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) = 'integer ')
Begin
Select @ v_UpperStr = 'zero-yuan unival'
End
Select @ ret = @ v_UpperStr
GO
-- Call process:
Declare @ ret varchar (200)
Exec L2 U 567983.897, 1, @ ret output
Select @ ret