使用CAMA在Word中转换数字(数字,数字)

时间:2019-02-12 09:02:03

标签: sql sql-server tsql

在这方面我需要帮助,因为我想阅读以下示例中的数字。

原始值:3 458,98

返回值:

TROIS MILLE QUATRE CENT CINQUANTE HUIT EURO QUATRE VINGT DIX HUIT CENTIMES

1 个答案:

答案 0 :(得分:0)

类似的东西:

DECLARE @numbers VARCHAR(50) = '3458.98'
        , @WordsString varchar(max)

SELECT @WordsString = COALESCE(@WordsString + ', ', '')  + o.word
FROM 
(
SELECT 
CASE WHEN q.ch NOT LIKE '%[^0-9]%' AND q.ch = 3 THEN ' THREE'    
     WHEN q.ch NOT LIKE '%[^0-9]%' AND q.ch = 4 THEN ' FOUR'    
     WHEN q.ch NOT LIKE '%[^0-9]%' AND q.ch = 5 THEN ' FIVE'    
     WHEN q.ch NOT LIKE '%[^0-9]%' AND q.ch = 8 THEN ' EIGHT'    
     WHEN q.ch NOT LIKE '%[^0-9]%' AND q.ch = 9 THEN ' NINE'    
     ELSE Q.ch
   END word
FROM 
(select substring(a.b, v.number+1, 1) ch
from (select @numbers b) a
join master..spt_values v on v.number < len(a.b)
where v.type = 'P'
)q
)o

SELECT @WordsString

输出:

 THREE,  FOUR,  FIVE,  EIGHT, .,  NINE,  EIGHT