// Query
create function Currency_Format(@ValToConver
float,@CommaInt
int)
returns varchar(200)
as
begin
declare
@RepsVal varchar(50)
declare @p1 varchar(40)
declare @p2 varchar(10)
set @RepsVal = replace(convert (varchar(20), convert(money, @ValToConver), 3 ) , ',','')
set @p1 = left(@RepsVal, charindex('.', @RepsVal)-1)
set @p2 = substring(@RepsVal, charindex('.', @RepsVal), 10)
set @RepsVal = right(@p1, 3) + @p2
set @p1 = left(@p1, len(@p1)-3)
while (@p1<>'')
begin
set
@RepsVal = right(@p1, @CommaInt) + ',' + @RepsVal
if (len(@p1) > @CommaInt)
set @p1 = left(@p1, len(@p1)-@CommaInt)
else
set @p1= ''
end
return(@RepsVal)
end
/// Result
No comments:
Post a Comment