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. linux资源使用配置文件 /etc/security/limits.conf和ulimit

    limits.conf文件实际上是linux PAM中pam_limits.so的配置文件,而且只针对于单个会话. limits.conf的格式如下: <domain> <type& ...

  2. TokuDB 引擎安装测试

    背景: TokuDB引擎是有Tokutek开发的一个数据库存储引擎,在设计之初便引入了独特的索引算法,在其官网测试的文章中看到TokuDB性能比InnoDB高出很多. MySQL是一个插件式的数据库, ...

  3. IEEE802.15.4 部分无线收发芯片比较

    见下表:   TI(CC2530&CC2520) ST(STM32W108) Atmel(AT86RF231) 功耗(发送功率0DB) 30mA 31mA 14mA 是否提供手册 提供 不提供 ...

  4. 初次使用 VUX

    1. 因为以前没用过vux ,所以还是比较不熟练: 2.项目部署是根据git上的源码改的: 开始:将git上的项目下载或者clone到本地: 001:安装nodejs--> 002:npm in ...

  5. css 命名规范

    网站头部:    head/header(头部) top(顶部)    导航:   nanv 导航具体区分:topnav(顶部导航).mainnav(主导航).mininav(迷你导航).textna ...

  6. 【xml】转义字符 &lt;等符号出现的原因

    来源:http://www.cnblogs.com/hyd309/p/3549076.html HTML中的转义字符  HTML中<, >,&等有特别含义,(前两个字符用于链接签, ...

  7. curl命令 抓取网络数据相应头

    curl --verbose  --data "Password=123&Username=158101068&url=http://m.vancl.com/" & ...

  8. 自定义Button 的图片设置不显示问题。

    如果你是自定义button  那么你设置图片就要用 button.imageView.image = [UIImage imageName:@""]; 如果你是给系统原生的butt ...

  9. Java多线程题库

    一.    填空题 处于运行状态的线程在某些情况下,如执行了sleep(睡眠)方法,或等待I/O设备等资源,将让出CPU并暂时停止自己的运行,进入____阻塞_____状态. 处于新建状态的线程被启动 ...

  10. java annotation

    import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.an ...