下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
CREATE FUNCTION usf_ChineseCost ( @Cost float ) RETURNS varchar(50) AS ----大写钱数---- BEGIN declare @returnStr varchar(50) if (@Cost >= 1000000000) Begin set @returnStr = '##########' return @returnStr end set @returnStr = '00000000000' set @returnStr = right(@returnStr + convert(varchar,convert(decimal(11,2),round(@cost,2))),12) set @returnStr = replace(@returnStr,'0','零') set @returnStr = replace(@returnStr,'1','壹') set @returnStr = replace(@returnStr,'2','贰') set @returnStr = replace(@returnStr,'3','叁') set @returnStr = replace(@returnStr,'4','肆') set @returnStr = replace(@returnStr,'5','伍') set @returnStr = replace(@returnStr,'6','陆') set @returnStr = replace(@returnStr,'7','柒') set @returnStr = replace(@returnStr,'8','捌') set @returnStr = replace(@returnStr,'9','玖') set @returnStr = @returnStr + '分' set @returnStr = stuff(@returnStr,len(@returnStr)-1,'角') set @returnStr = replace(@returnStr,'.','元') set @returnStr = stuff(@returnStr,len(@returnStr)-5,'拾') set @returnStr = stuff(@returnStr,len(@returnStr)-7,'百') set @returnStr = stuff(@returnStr,len(@returnStr)-9,'千') set @returnStr = stuff(@returnStr,len(@returnStr)-11,'万') set @returnStr = stuff(@returnStr,len(@returnStr)-13,len(@returnStr)-15,len(@returnStr)-17,len(@returnStr)-19,'亿') set @returnStr = replace(@returnStr,'零亿','零') set @returnStr = replace(@returnStr,'零千','零百','零拾','零零零','零零','零万','万') set @returnStr = replace(@returnStr,'零元','元') set @returnStr = replace(@returnStr,'零角','零分','') while left(@returnStr,1) = '零' Begin set @returnStr = right(@returnStr,len(@returnStr)-1) end if ((left(@returnStr,1)='万')) begin set @returnStr = right(@returnStr,len(@returnStr)-1) end if ((left(@returnStr,1)='元')) begin set @returnStr = right(@returnStr,len(@returnStr)-1) end while left(@returnStr,len(@returnStr)-1) end while right(@returnStr,1) = '零' Begin set @returnStr = left(@returnStr,len(@returnStr)-1) end set @returnStr = replace(@returnStr,'亿万','亿零') set @returnStr = replace(@returnStr,'零') if (@returnStr='') begin set @returnStr = '零元' end if ((right(@returnStr,1)='元')) begin set @returnStr = @returnStr + '整' end return @returnStr END
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
原文链接:/mysql/456556.html