/**//* 将数字转换成大写金额的函数 */ CREATEFUNCTION GetChineseNum (@inputIdmoney) RETURNSNvarchar(4000) AS BEGIN declare@rVNvarchar(4000) declare@tmpstrNvarchar(4000),@MNvarchar(4000),@KNvarchar(4000),@I numeric(38,2), @Jint,@lastJint,@LastVNvarchar(10),@LastFNvarchar(10),@LastENvarchar(10),@LastVENvarchar(10) set@I=@inputId select@tmpstr=N'零壹贰叁肆伍陆柒捌玖分角元拾佰仟万拾佰仟亿拾佰仟',@K=N'',@M=cast(cast(@I*100asbigint) asvarchar(800)),@J=len(@M),@LastVE=N'' while@J>=1 begin set@LastF=substring(@tmpstr, cast(substring(@m,len(@M)-@j+1,1) asbigint)+1,1) set@LastE=substring(@tmpstr,10+@J,1) if@LastF<>N'零' begin if@LastV=N'零' if (@lastJ>=7and@j<=7) or (@lastJ>=11and@j<=11 ) or (@lastJ>=3and@j<=2) if@J<=2and@lastJ<=3 set@K=@K+@LastVE+@LastF+@LastE else set@K=@K+@LastVE+@LastV+@LastF+@LastE else set@K=@K+@LastV+@LastF+@LastE else set@K=@K+@LastF+@LastE select@lastJ=@j,@LastVE=N'' end else begin if@LastVE=N''and@lastJ>11set@LastVE=N'亿' if@LastVE=N''and@lastJ>7and@lastJ<10set@LastVE=N'万' if@LastVE=N''and@lastJ>3and@lastJ<6set@LastVE=N'元' if@LastV<>N'零'set@lastJ=@j end set@LastV=@LastF set@J=@J-1 end if@lastJ>=3set@K=@K+N'元' if@lastJ>=2set@K=@K+N'整' set@rv=@K return@rv END