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. ACM/ICPC 之 数据结构-线段树+区间离散化(POJ2528)

    这道题用线段树做更方便更新和查询,但是其数据范围很大,因此要将离散化和线段树结合起来,算是一道比较经典的线段树+离散化的例题. 线段树的离散化有很多方法,在这里,我先用一次结点离散化,间接将源左右端点 ...

  2. [Android Studio导入第三方类库方法] Error:(19, 23) 错误: 程序包org.apache.http不存在

    本文主要参考以下链接: http://m.blog.csdn.net/blog/BoxRice/48575027 https://drakeet.me/android-studio http://ww ...

  3. [ 转] [Android]多式样ProgressBar

    多式样ProgressBar 普通圆形ProgressBar 该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中. 一般只要在XML布局中定义就可以了. < ...

  4. 记录linux系统用户shell终端操作记录

    在 /etc/profile 最后添加 export HISTTIMEFORMAT='[%F %T]: ' export PROMPT_COMMAND='{ msg=$(history 1 | { r ...

  5. maven加载本地lib下的jar包

    1.本地lib下有jar 2.命令: mvn install:install-file -Dfile=juh-3.0.1.jar -DgroupId=org.openoffice -Dartifact ...

  6. myeclipse破解

    由于内容比较多,我就直接转载了 ,同时感谢原博主 http://blog.itpub.net/27042095/viewspace-1164998/

  7. Tmux的安装、使用与配置

    tmux 安装.使用.配置 因上线需求,故需要使用tumx,方便上线 tmux功能 提供了强大的.易于使用的命令行界面 可横向.纵向分割窗口 窗格可以自由移动和调整大小,或者直接利用四个预设布局之一 ...

  8. 关于Visual Studio 2013 编译 multi-byte character set MFC程序出现 MSB8031 错误的解决办法

    转自:http://blog.csdn.net/xiaochunzao/article/details/16987703 Visual Studio 2013 编译旧的 multi-byte char ...

  9. 线程变量ThreadLocal的使用

    我们有时候会通过token进行多次查询(猪:token是redis中的key),比如: 一次是在登录拦截器中,一次是在controller的业务中查询,这样存在性能和资源的浪费问题!!! 那么如何将拦 ...

  10. 关于HTML5在动画制作工具Animatron的一些问题

    Animatron是国外一款在线HTML5动画制作工具,网址:www.animatron.com 当然,想使用的话,是需要FQ的. 用animatron制作好的动画是可以下载为代码和GIF的,这时候付 ...