create function [dbo].[f_num_chn] (@num numeric(14,2)) returns varchar(100) with encryption as begin --版权所有:pbsql declare @n_data varchar(20),@c_data varchar(100),@n_str varchar(10),@i int
set @n_data=right(space(14)+cast(cast(abs(@num*100) as bigint) as varchar(20)),14) set @c_data='' set @i=1 while @i<=14 begin set @n_str=substring(@n_data,@i,1) if @n_str<>' ' begin if not ((substring(@n_data,@i,2)='00') or ((@n_str='0') and ((@i=4) or (@i=8) or (@i=12) or (@i=14)))) set @[email protected]_data+substring('零壹贰叁肆伍陆柒捌玖',cast(@n_str as int)+1,1) if not ((@n_str='0') and (@i<>4) and (@i<>8) and (@i<>12)) set @[email protected]_data+substring('仟佰拾亿仟佰拾万仟佰拾圆角分',@i,1) if substring(@c_data,len(@c_data)-1,2)='亿万' set @c_data=substring(@c_data,1,len(@c_data)-1) end set @[email protected]+1 end if @num<0 set @c_data='(负数)'[email protected]_data if @num=0 set @c_data='零圆' if @n_str='0' set @[email protected]_data+'整' return(@c_data) end