create function UpperRMB(@num numeric(14,2))
returns @rmb table(
亿 varchar(2)
,仟万 varchar(2)
,佰万 varchar(2)
,拾万 varchar(2)
,万 varchar(2)
,仟 varchar(2)
,佰 varchar(2)
,拾 varchar(2)
,元 varchar(2)
,角 varchar(2)
,分 varchar(2))
as
begin
insert into @rmb
select
(case 亿1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 亿,
(case 仟万1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 仟万,
(case 佰万1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 佰万,
(case 拾万1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 拾万,
(case 万1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 万,
(case 仟1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 仟,
(case 佰1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 佰,
(case 拾1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 拾,
(case 元1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 元,
(case 角1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 角,
(case 分1
when 0 then '零'
when 1 then '壹'
when 2 then '贰'
when 3 then '叁'
when 4 then '肆'
when 5 then '伍'
when 6 then '陆'
when 7 then '柒'
when 8 then '捌'
when 9 then '玖'
else '' end) as 分
from (
select
case when len(ltrim(str(@num*100,14)))>=11
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),11),1) ) else null end as 亿1,
case when len(ltrim(str(@num*100,14)))>=10
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),10),1) ) else null end as 仟万1,
case when len(ltrim(str(@num*100,14)))>=9
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),9),1) ) else null end as 佰万1,
case when len(ltrim(str(@num*100,14)))>=8
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),8),1) ) else null end as 拾万1,
case when len(ltrim(str(@num*100,14)))>=7
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),7),1) ) else null end as 万1,
case when len(ltrim(str(@num*100,14)))>=6
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),6),1) ) else null end as 仟1,
case when len(ltrim(str(@num*100,14)))>=5
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),5),1) ) else null end as 佰1,
case when len(ltrim(str(@num*100,14)))>=4
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),4),1) ) else null end as 拾1,
case when len(ltrim(str(@num*100,14)))>=3
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),3),1) ) else null end as 元1,
case when len(ltrim(str(@num*100,14)))>=2
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),2),1) ) else null end as 角1,
case when len(ltrim(str(@num*100,14)))>=1
then convert(varchar(10),left(right(ltrim(str(@num*100,14)),1),1) ) else null end as 分1
) kk
return
end /*
select * from upperrmb(123456789.12) select 亿+'亿'+仟万+'仟'+佰万+'佰'+拾万+'拾'+万+'万'+仟+'仟'+佰+'佰'+拾+'拾'+元+'元'+角+'角'+分+'分' AS [人民币大写]
from upperrmb(123456789.12) --其实单位也可以在函数内设定
*/

sql 数字转人民币大写函数(两种方法)的更多相关文章

  1. SQL Server 批量插入数据的两种方法

    在SQL Server 中插入一条数据使用Insert语句,但是如果想要批量插入一堆数据的话,循环使用Insert不仅效率低,而且会导致SQL一系统性能问题.下面介绍 SQL Server支持的两种批 ...

  2. SQL Server 批量插入数据的两种方法(转)

    此文原创自CSDN TJVictor专栏:http://blog.csdn.net/tjvictor/archive/2009/07/18/4360030.aspx 在SQL Server 中插入一条 ...

  3. 转:SQL Server 批量插入数据的两种方法

    在SQL Server 中插入一条数据使用Insert语句,但是如果想要批量插入一堆数据的话,循环使用Insert不仅效率低,而且会导致SQL一系统性能问题.下面介绍SQL Server支持的两种批量 ...

  4. asp.net中TextBox只能输入数字的最简洁的两种方法

    如下TextBox <asp:textboxonkeypress="isnum()"id="TextBox1"runat="server&quo ...

  5. 数字转人民币大写(SQL SERVER)

    --数字转人民币大写NumToRMB ---新建方法create  FUNCTION dbo.NumToRMB (@num numeric(14,5))   RETURNS varchar(100) ...

  6. C++关于数字逆序输出的两种思路,及字符串逆序输出

    C++关于数字逆序输出的两种思路,及字符串逆序输出 作者:GREATCOFFEE 发布时间:NOVEMBER 15, 2012 分类:编程的艺术 最近在跟女神一起学C++(其实我是不怀好意),然后女神 ...

  7. EntityFramework Core 2.0自定义标量函数两种方式

    前言 上一节我们讲完原始查询如何防止SQL注入问题同时并提供了几种方式.本节我们继续来讲讲EF Core 2.0中的新特性自定义标量函数. 自定义标量函数两种方式 在EF Core 2.0中我们可以将 ...

  8. 【PHP】数字补零的两种方法

    在php中有两个函数,能够实现数字补零, str_pad() sprintf() 函数1 : str_pad 顾名思义这个函数是针对字符串来说的这个可以对指定的字符串填补任何其它的字符串 例如:str ...

  9. SQL Server 2008 数据库同步的两种方式 (发布、订阅)

    参考转载: SQL Server 2008 数据库同步的两种方式 (发布.订阅) 使用Sqlserver事务发布实现数据同步

随机推荐

  1. (转)C++0x语言新特性一览

    转自:http://blog.csdn.net/zwvista/article/details/2429781 原文请见http://en.wikipedia.org/wiki/C%2B%2B0x. ...

  2. MySQL排序原理与MySQL5.6案例分析【转】

    本文来自:http://www.cnblogs.com/cchust/p/5304594.html,其中对于自己觉得是重点的加了标记,方便自己查阅.更多详细的说明可以看沃趣科技的文章说明. 前言    ...

  3. winrt控件

    http://www.mindscapehq.com/products/metroelements 常见的翻书,相册,图表,时间组件 demo下载地址http://assets.mindscape.c ...

  4. nyoj113_字符串替换

    字符串替换 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 编写一个程序实现将字符串中的所有"you"替换成"we"   输入 ...

  5. 【剑指offer】题目36 数组中的逆序对

    数组中任取两个数字,如果前面的数字大于后面的数字称为一个逆序对 如:1,2,1,2,1 有3个逆序对 思路:知道O(N2)肯定是错的.开始想hash,试图找到O(n)的算法,想了很久,找不到.后来想到 ...

  6. HDU 5881 Tea -2016 ICPC 青岛赛区网络赛

    题目链接 题意:有一壶水, 体积在 L和 R之间, 有两个杯子, 你要把水倒到两个杯子里面, 使得杯子水体积几乎相同(体积的差值小于等于1), 并且使得壶里剩下水体积不大于1. 你无法测量壶里剩下水的 ...

  7. php与xpath使用操作文本节点

    <?php $html="<p> 对于2014年,省统计局的统计分析显示,我省消费流通领域受诸多因素的影响,有机遇也有挑战.但值得注意的是,消费增长还存在不少制约因素,比如 ...

  8. [Android Pro] InputStream.skip方法的思考

    参考 : http://blog.csdn.net/gsyzhu/article/details/8102286 在java.io.InputStream类中定义了skip这个方法.在API中的描述如 ...

  9. August 26th 2016 Week 35th Friday

    It always seems impossible until it's done. 在事情未完成之前,一切都看似不可能. When I was young, once I had to lift ...

  10. mongodb3.x版本用户管理方法

    db.auth() 作用:验证用户到数据库. 语法: db.auth( { user: <username>, pwd: <password>, mechanism: < ...