惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - music000

分享:使用JQuery进行跨域请求 Flash Chart 谨防 url 传递参数未编码(转码)产生的陷阱 OSI七层网络模型与TCP/IP四层网络模型 一些数据库理论知识 Sqlserver中Compute By子句用法分析 数据查询的另类需求 A Preview of HTML 5 CSS Sprites 15 Rules for Faster-Loading Web Sites 关于"多级目录(分类)"的一些想法 ----- 实现方法 金额转换:阿拉伯数字转中文(javascript) 这两天不爽——公车上被误认为色狼、游泳撞破上嘴唇 如何获取字段中分隔符的个数?(sql语句) 关于GridView导出Excel的一些问题(采用Ajax出现的的问题及解决方法) - music000 - 博客园 固定表头 Bubble in JavaScript DOM Reg-日期 安装 WebDesigner 之后,ASPNET 帐户没有对 IIS 的访问权。
金额转换:阿拉伯数字转中文(SQL存储过程)
music000 · 2007-09-15 · via 博客园 - music000

刚发了一个 javascript 版的,再发一个 SQL 存储过程版本的
copy 于:金额阿拉伯数字转换为中文的存储过程 (TSD的专栏)

Create    Procedure    AtoC 
    @ChangeMoney    Money    
as
    Set Nocount ON
    Declare    @String1    char(20)
    Declare    @String2    char(30)
    Declare    @String4    Varchar(100)
    Declare @String3     Varchar(100)    --从原A值中取出的值
        Declare @i         int        --循环变量
    Declare @J         Int        --A的值乘以100的字符串长度
        Declare @Ch1         Varchar(100)    --数字的汉语读法
        Declare @Ch2         Varchar(100)    --数字位的汉字读法
    Declare @Zero         Int        --用来计算连续有几个零
    Declare    @ReturnValue    VarChar(100)

    Select @ReturnValue = ''
    Select     @String1 = '零壹贰叁肆伍陆柒捌玖'
    Select    @String2 = '万仟佰拾亿仟佰拾万仟佰拾元角分'

    Select @String4 = Cast(@ChangeMoney*100 as int)    

    select @J=len(cast((@ChangeMoney*100) as int))

    Select @String2=Right(@String2,@J)

    Select    @i = 1

    while    @i<= @j Begin

        Select @String3 = Substring(@String4,@i,1)

        if @String3<>'0' Begin

            Select     @Ch1 = Substring(@String1, Cast(@String3 as Int) + 1, 1)
            Select    @Ch2 = Substring(@String2, @i, 1)
            Select    @Zero = 0                    --表示本位不为零
        end
        else Begin
            If (@Zero = 0) Or (@i = @J - 9) Or (@i = @J - 5) Or (@i = @J - 1)
                        Select @Ch1 = '零'
                    Else
                        Select @Ch1 = ''

                    Select @Zero = @Zero + 1             --表示本位为0
                        
            --如果转换的数值需要扩大,那么需改动以下表达式 I 的值。
            Select Ch2 = ''

                If @i = @J - 10  Begin
                        Select @Ch2 = '亿'
                        Select @Zero = 0
            end
                    
            If @i = @J - 6 Begin
                        Select @Ch2 = '万'
                        Select @Zero = 0
            end
                    
            if @i = @J - 2 Begin
                        Select @Ch2 = '元'
                        Select @Zero = 0
            end
                    
            If @i = @J
                        Select @Ch2 = '整'
                        
        end    

        Select @ReturnValue = @ReturnValue + @Ch1 + @Ch2

        select @i = @i+1
    end

    --最后将多余的零去掉
    If CharIndex('仟仟',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '仟仟', '仟')

    If CharIndex('佰佰',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '佰佰', '佰')

        If CharIndex('零元',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '零元', '元')
    
        If CharIndex('零万',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '零万', '万')
   
        If CharIndex('零亿',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '零亿', '亿')
    
        If CharIndex('零整',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '零整', '整')
    
    If CharIndex('零佰',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '零佰', '零')

    If CharIndex('零仟',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '零仟', '零')

    If CharIndex('元元',@ReturnValue) <> 0
            Select @ReturnValue = Replace(@ReturnValue, '元元', '元')
    
    Select @ReturnValue
GO