Converting / Casting an nVarChar with Comma Separator to Decimal

后端 未结 4 797
无人共我
无人共我 2020-12-11 17:11

I am supporting an ETL process that transforms flat-file inputs into a SqlServer database table. The code is almost 100% T-SQL and runs inside the DB. I do not own the code

4条回答
  •  春和景丽
    2020-12-11 17:59

    try using REPLACE (Transact-SQL):

    SELECT REPLACE('12,345.67',',','')
    

    OUTPUT:

    12345.67
    

    so it would be:

    SELECT FLOOR( CAST(REPLACE([input value],',','') AS DECIMAL(24,10)))
    

提交回复
热议问题