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. 算法手记 之 数据结构(线段树详解)(POJ 3468)

    依然延续第一篇读书笔记,这一篇是基于<ACM/ICPC 算法训练教程>上关于线段树的讲解的总结和修改(这本书在线段树这里Error非常多),但是总体来说这本书关于具体算法的讲解和案例都是不 ...

  2. K3安装记录

    安装的某些客户端没有客户端管理工具,测试问题所在 K3安装目录选择到D盘就可以,它自动生成kingdee\k3路径

  3. Mathematics:DNA Sorting(POJ 1007)

    DNA排序 题目大意:给定多个ACGT序列,按照字母顺序算出逆序数,按逆序数从小到大排列 这题其实很简单,我们只要用一个归并排序算逆序数,然后快排就可以了(插入排序也可以,数据量不大),但是要注意的是 ...

  4. php中文转换编码函数

    $filename= $list->filename; // 获取文件名字 if(preg_match("/[\x80-\xff]/",$filename)){ // 如果是 ...

  5. db2中报SQLCODE=-530, SQLSTATE=23503错误

    今天在写一个增加操作时,报错信息如下:SQLCODE=-530, SQLSTATE=23503,该sqlcode说明:“对特定的约束名指定了无效的外健值”. 项目中用的框架是SSH,新增的主对象有多个 ...

  6. window.parent 与 window.opener

    window.parent针对iframe,window.opener针对window.open 父页面parent.jsp: <%@ page language="java" ...

  7. Hibernate 所有缓存机制详解

    hibernate提供的一级缓存 hibernate是一个线程对应一个session,一个线程可以看成一个用户.也就是说session级缓存(一级缓存)只能给一个线程用,别的线程用不了,一级缓存就是和 ...

  8. DX使用texconv工具批处理dds格式图片

    texconv D:\png\*.* -o E:\dds -m 5 -f dxt3 -ft dds 上述命令的意思是把D:\png目录下的全部文件(当然可以指定特定格式例如*.png)转换成dds格式 ...

  9. W3C对DOM2.0定义的标准事件

    DOM2.0模型将事件处理流程分为三个阶段: 一.事件捕获阶段, 二.事件目标阶段, 三.事件起泡阶段. 具体如图(图片来源于网络,侵删) 事件捕获:当某个元素触发某个事件(如onclick),顶层对 ...

  10. Mysql之高可用

    使用缓存Memcache, 1,可使用Hash算法由客户端决定路由到哪个Memcache服务器上:客户端完全不用关心数据存储在哪个Memcache服务器上:完全隔离了客户端与服务端:由于是Hash,在 ...