sqlserver 人民币数字转大写

sqlserver 人民币数字转大写,第1张

概述/*调用过程: declare @ret varchar(200)exec L2U 123456789.897,1,@ret outputselect @ret*/CREATE PROCEDURE dbo.L2U (@n_LowerMoney numeric(15,2),@v_TransType int,@RET VARCHAR(200) output) AS D
/*调用过程:	declare @ret varchar(200)exec L2U 123456789.897,1,@ret outputselect @ret*/CREATE PROCEDURE dbo.L2U (@n_LowerMoney numeric(15,2),@v_TransType int,@RET VARCHAR(200) output) AS   Declare @v_LowerStr VARCHAR(200) -- 小写金额 Declare @v_UpperPart VARCHAR(200) Declare @v_UpperStr VARCHAR(200) -- 大写金额Declare @i_I intset nocount onselect @v_LowerStr = LTRIM(RTRIM(STR(@n_LowerMoney,20,2))) --四舍五入为指定的精度并删除数据左右空格select @i_I = 1select @v_UpperStr = ''while ( @i_I <= len(@v_LowerStr))begin	select @v_UpperPart = case substring(@v_LowerStr,len(@v_LowerStr) - @i_I + 1,1)		 WHEN  '.' THEN  '元'							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  '玖'							END							+ 							case @i_I							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  '拾'							WHEN  10  THEN  '佰'							WHEN  11  THEN  '仟'							WHEN  12  THEN  '亿'							WHEN  13  THEN  '拾'							WHEN  14  THEN  '佰'							WHEN  15  THEN  '仟'							WHEN  16  THEN  '万'		ELSE ''						  ENDselect @v_UpperStr = @v_UpperPart + @v_UpperStrselect @i_I = @i_I + 1end--------print  '//v_UpperStr ='+@v_UpperStr +'//'if ( @v_TransType=0 )beginselect @v_UpperStr = REPLACE(@v_UpperStr,'零拾','零') select @v_UpperStr = REPLACE(@v_UpperStr,'零佰','零仟','零零零','零')select @v_UpperStr = REPLACE(@v_UpperStr,'零零','零角零分','整')select @v_UpperStr = REPLACE(@v_UpperStr,'零分','零角','零亿零万零元','亿元')select @v_UpperStr = REPLACE(@v_UpperStr,'亿零万零元','零亿零万','亿')select @v_UpperStr = REPLACE(@v_UpperStr,'零万零元','万元')select @v_UpperStr = REPLACE(@v_UpperStr,'万零元','零亿','零万','万')select @v_UpperStr = REPLACE(@v_UpperStr,'零元','元')select @v_UpperStr = REPLACE(@v_UpperStr,'零')end-- 对壹元以下的金额的处理 if ( substring(@v_UpperStr,1)='元' )begin	 select @v_UpperStr = substring(@v_UpperStr,2,(len(@v_UpperStr) - 1))endif (substring(@v_UpperStr,1)= '零')begin	select @v_UpperStr = substring(@v_UpperStr,1)='角')begin	 select @v_UpperStr = substring(@v_UpperStr,(len(@v_UpperStr) - 1))endif ( substring(@v_UpperStr,1)='分')begin	select @v_UpperStr = substring(@v_UpperStr,1)='整')begin	select @v_UpperStr = '零元整'endselect @ret=@v_UpperStrGO
总结

以上是内存溢出为你收集整理的sqlserver 人民币数字转大写全部内容,希望文章能够帮你解决sqlserver 人民币数字转大写所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1177080.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存