将小写金额转换为中文大写的SQL函数

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

CREATEFUNCTION[dbo].[f_num_chn](@numnumeric(14,2))
RETURNSvarchar(100)WITHENCRYPTION
AS
BEGIN
--版权所有:pbSQL
 DECLARE@n_dataVARCHAR(20),@c_dataVARCHAR(100),@n_strVARCHAR(10),@iint

 SET@n_data=RIGHT(SPACE(14)+CAST(CAST(ABS(@num*100)ASbigint)ASvarchar(20)),14)
 SET@c_data=''
 SET@i=1
 WHILE@i<=14
 BEGIN
   SET@n_str=SUBSTRING(@n_data,@i,1)
   IF@n_str<>''
   BEGIN
     IFnot((SUBSTRING(@n_data,@i,2)='00')or
       ((@n_str='0')and((@i=4)or(@i=8)or(@i=12)or(@i=14))))
       SET@c_data=@c_data+SUBSTRING('零壹贰叁肆伍陆柒捌玖',CAST(@n_strASint)+1,1)
     IFnot((@n_str='0')and(@i<>4)and(@i<>8)and(@i<>12))
       SET@c_data=@c_data+SUBSTRING('仟佰拾亿仟佰拾万仟佰拾圆角分',@i,1)
     IFSUBSTRING(@c_data,LEN(@c_data)-1,2)='亿万'
       SET@c_data=SUBSTRING(@c_data,1,LEN(@c_data)-1)
   END
   SET@i=@i+1
 END
 IF@num<0
   SET@c_data='(负数)'+@c_data
 IF@num=0
   SET@c_data='零圆'
 IF@n_str='0'
   SET@c_data=@c_data+'整'
 RETURN(@c_data)
END


<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
文章标签: sql c
个人分类: 数据库
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭