SQL number to Chinese uppercase

Time:2020-4-22

USE [SPECIAL_BLD]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[get_upper]
(
@num numeric(18,5)
)
RETURNS VARCHAR(500)
AS
BEGIN
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 (‘one two three four five six seven eight nine ‘, cast (@ n_str as int) + 1,1)
IF not ((@n_str=’0′) and (@i<>4) and (@i<>8) and (@i<>12))
Set @ c_data = @ c_data + subscribing (’10 billion billion, 100 million, 100% round corner points’, @ I, 1)
If substring (@ c’u data, len (@ c’u data) – 1,2) = ‘billions’
SET @c_data=SUBSTRING(@c_data,1,LEN(@c_data)-1)
END
SET @[email protected]+1
END
IF @num<0
Set @ c_data = ‘(negative number)’ + @ c_data
IF @num=0
Set @ c_data = ‘zero circle’
IF @n_str=’0′
Set @ c’data = @ c’data + ‘whole’
RETURN(@c_data)
END
GO

Recommended Today

JS function

1. Ordinary function Grammar: Function function name (){ Statement block } 2. Functions with parameters Grammar: Function function name (parameter list){ Statement block } 3. Function with return value Grammar: Function function name (parameter list){ Statement block; Return value; } Allow a variable to accept the return value after calling the function Var variable name […]