create function UpperRMB(@num numeric(14,2)) returns @rmb table( 亿 varchar(2) ,仟万 varchar(2) ,佰万 varchar(2) ,拾万 varchar(2) ,万 varchar(2) ,仟 varchar(2) ,佰 varchar(2) ,拾 varchar(2) ,元 varchar(2) ,角 varchar(2) ,分 varchar(2)) as begin insert into @rmb select (case 亿1 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 '玖' else '' end) as 亿, (case 仟万1 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 '玖' else '' end) as 仟万, (case 佰万1 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 '玖' else '' end) as 佰万, (case 拾万1 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 '玖' else '' end) as 拾万, (case 万1 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 '玖' else '' end) as 万, (case 仟1 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 '玖' else '' end) as 仟, (case 佰1 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 '玖' else '' end) as 佰, (case 拾1 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 '玖' else '' end) as 拾, (case 元1 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 '玖' else '' end) as 元, (case 角1 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 '玖' else '' end) as 角, (case 分1 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 '玖' else '' end) as 分 from ( select case when len(ltrim(str(@num*100,14)))>=11 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),11),1) ) else null end as 亿1, case when len(ltrim(str(@num*100,14)))>=10 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),10),1) ) else null end as 仟万1, case when len(ltrim(str(@num*100,14)))>=9 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),9),1) ) else null end as 佰万1, case when len(ltrim(str(@num*100,14)))>=8 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),8),1) ) else null end as 拾万1, case when len(ltrim(str(@num*100,14)))>=7 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),7),1) ) else null end as 万1, case when len(ltrim(str(@num*100,14)))>=6 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),6),1) ) else null end as 仟1, case when len(ltrim(str(@num*100,14)))>=5 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),5),1) ) else null end as 佰1, case when len(ltrim(str(@num*100,14)))>=4 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),4),1) ) else null end as 拾1, case when len(ltrim(str(@num*100,14)))>=3 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),3),1) ) else null end as 元1, case when len(ltrim(str(@num*100,14)))>=2 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),2),1) ) else null end as 角1, case when len(ltrim(str(@num*100,14)))>=1 then convert(varchar(10),left(right(ltrim(str(@num*100,14)),1),1) ) else null end as 分1 ) kk return end /* select * from upperrmb(123456789.12) select 亿+'亿'+仟万+'仟'+佰万+'佰'+拾万+'拾'+万+'万'+仟+'仟'+佰+'佰'+拾+'拾'+元+'元'+角+'角'+分+'分' AS [人民币大写] from upperrmb(123456789.12) --其实单位也可以在函数内设定 */