with t as ( select '-' as col1 --isnumeric('-')這里會判斷為數字,所以不能用 union all select '1' as col1 union all select '2' as col1 union all select '3.4' as col1 union all select 's' as col1 ) select col1, convert(numeric(10,4), -- case WHEN isnumeric(col1)=1 then col1 else 0*1.0 end case WHEN PATINDEX('%[^0-9|.|-|+]%',col1)=0 THEN col1 ELSE 0*1.0 end ) as cc from t
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/4134.html
標籤:SQL Server
上一篇:一個簡單的交叉報表_行轉列
