The function realization of RMB-to-Capital in SQL Server

Source: Internet
Author: User

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

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.