I have a Exg:
CREATE PROCEDURE dbo.submoney (
@amt numeric(10, 2),
@L1 char(1) output,
@L2 char(1) output,
@L3 char(1) output,
@L4 char(1) output,
@L5 char(1) output,
@L6 char(1) output,
@L7 char(1) output,
@L8 char(1) output,
@L9 char(1) output,
@L10 char(1) output,
@amtC char(64) output) AS
declare @s char(11)
declare @i integer
declare @C char(1)
declare @f integer
declare @C1 char(2)
select @f=0
select @s=convert(char(11),@amt)
select @i=charindex('.',@s)
select @s=stuff('000000000',10-@i,@i-1,@s)
/*----------------L1--------------*/
select @C=substring(@s,1,1)
if @C<>'0'
begin
select @f=1
select @L1=@C
end
else
select @L1=' '
/*----------------L2--------------*/
select @C=substring(@s,2,1)
if @f=1
select @L2=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L2=@C
end
else
select @L2=' '
end
/*----------------L3--------------*/
select @C=substring(@s,3,1)
if @f=1
select @L3=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L3=@C
end
else
select @L3=' '
end
/*----------------L4--------------*/
select @C=substring(@s,4,1)
if @f=1
select @L4=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L4=@C
end
else select @L4=' '
end
/*----------------L5--------------*/
select @C=substring(@s,5,1)
if @f=1
select @L5=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L5=@C
end
else select @L5=' '
end
/*----------------L6--------------*/
select @C=substring(@s,6,1)
if @f=1
select @L6=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L6=@C
end
else select @L6=' '
end
/*----------------L7--------------*/
select @C=substring(@s,7,1)
if @f=1
select @L7=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L7=@C
end
else select @L7=' '
end
/*----------------L8--------------*/
select @C=substring(@s,8,1)
if @f=1
select @L8=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L8=@C
end
else select @L8=' '
end
/*----------------L9--------------*/
select @C=substring(@s,10,1)
if @f=1
select @L9=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L9=@C
end
else
select @L9=' '
end
/*----------------L10--------------*/
select @C=substring(@s,11,1)
if @f=1
select @L10=@C
else
begin
if @C<>'0'
begin
select @f=1
select @L10=@C
end
else
select @L10=' '
end
/*======================================*/
/*L1*/
select @C1=
Case @L1
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
select @amtC=@C1+'千'
/*L2*/
select @C1=
Case @L2
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
select @amtC=@amtC+@C1+'百'
/*L3*/
select @C1=
Case @L3
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
select @amtC=@amtC+@C1+'拾'
/*L4*/
select @C1=
Case @L4
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
select @amtC=@amtC+@C1+'万'
/*L5*/
select @C1=
Case @L5
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
select @amtC=@amtC+@C1+'千'
/*L6*/
select @C1=
Case @L6
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
select @amtC=@amtC+@C1+'百'
/*L7*/
select @C1=
Case @L7
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
select @amtC=@amtC+@C1+'拾'
/*L8*/
select @C1=
Case @L8
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
select @amtC=@amtC+@C1+'元'
/*L9*/
select @C1=
Case @L9
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
select @amtC=@amtC+@C1+'角'
/*L10*/
select @C1=
Case @L10
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
select @amtC=@amtC+@C1+'分 '
hope it can help!