CREATE FUNCTION [dbo]. [F_num_chn] (@num numeric (14,5))
RETURNS varchar (+) with encryption
As
BEGIN
--All rights reserved:[email protected]
DECLARE @n_data varchar, @c_data varchar, @n_str varchar, @i int SET @n_data =right (SPACE) +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) = ' xx ') or
((@n_str = ' 0 ') and ((@i=4) or (@i=8) or (@i=12) or (@i=14)))
SET @[email protected]_data+substring (' 0 a three-Woolu qi Ba Jiu ', CAST (@n_str as int) +1,1)
IF not ((@n_str = ' 0 ') and (@i<>4) and (@i<>8) and (@i<>12))
SET @[email protected]_data+substring (' Qian Bai hundred million thousand hundred thousand gather round corner cent ', @i,1)
IF SUBSTRING (@c_data, LEN (@c_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) '[email protected]_data
IF @num =0
SET @c_data = ' 0 Circle '
IF @n_str = ' 0 '
SET @[email protected]_data+ ' whole '
RETURN (@c_data)
END
The function realization of RMB-to-Capital in SQL Server