I am trying to create a function to do the following formatting:

RIGHT(CONVERT(DECIMAL(@precision,@decimal),@number),@width)

Unfortunately DECIMAL is not a function and therefore does not take parameters it seems.

CREATE FUNCTION DigitFormat(@number as TEXT, @precision as INTEGER, @decimal as INTEGER, @width as INTEGER)
RETURNS VARCHAR(100)
BEGIN
declare @Return VARCHAR(100)
SET @Return = RIGHT(CONVERT(DECIMAL(@precision,@decimal),@number),@width)
return @Return
END

Is there a way to solve this? I tried using EXEC but got no where...

**View Complete Post**

## DI in MVC with dynamic parameters