tags:

views:

161

answers:

3

how to convert a numeric value into eng.words e.g 10 to ten in sql statement?

+2  A: 
DECLARE @INPUT int
SET @input = 1

SELECT CASE WHEN @INPUT = 1 THEN 'One' 
            WHEN @INPUT = 2 THEN 'Two'

etc...

            WHEN @INPUT = 10 THEN 'Ten'

END AS [Value]
Rafe Lavelle
A: 

If it is a large number, then you are best off creating a lookup table to do this for you. For a small number Ralph's solution is more than adequate.

Another option is to use an algorithm in another tier to do this for you- like the one discussed here. You could even write a stored procedure in C# if you wanted to.

RichardOD
Yep, I am assuming, simply from the phrasing of the question, a very small list of numbers
Rafe Lavelle
+2  A: 

Joe Celko suggests NUMTOWORDS,one of the implementations

prateek urmaliya