Friday, 18 July 2014

Function For Amount Conversion From Number to Word In Sql Server ...

Create FUNCTION [dbo].[Fn_numtowords]
(
@Param1 numeric(30,2)
)
RETURNS varchar(max)
AS
BEGIN
Declare @Ndec numeric(10,2)
Declare @NRet varchar(max)
Declare @NRetDec varchar(max)
Set @NRetDec=''
If @Param1 <> 0
Begin
Select @Ndec = @Param1  % convert( integer, floor(@Param1) )
Select @NRet = dbo.udf_Num_ToWords(convert( integer, floor(@Param1) ) )
End

--If Isnull( @Ndec ,0) <> 0
If @Param1 <> 0
Select @NRetDec = ' And ' +dbo.udf_Num_ToWords(@Ndec * 100 ) + ' Fils Only'
Else
 Select @NRetDec = 'Zero' 

No comments: