一、解決方案
2e-005 轉成 0.00002
update 表名 set 列名=cast(列名 as float) as decimal(19,5)) where 列名 like '%e%'
如果: 2e-006 轉成 0.000002 那麼 decimal(19,6) ,以此類推。
二、測試:
select cast(cast('+1.590759e+01' as float) as decimal(19,5))
結果: 15.90759
三、實際應用:
hg(汞,nvarchar型別,考慮到有大於小於符號所有用nvarchar型別儲存)
資料問題舉例:
<0.00001
3e-005
轉換:update waterqualitytemp set hg= cast(cast(hg as float) as decimal(19,5)) where hg like '%e%'
結果:
<0.00001
0.00003
四、另一種方法
--測試
select convert(decimal(19,5),convert(float,'+1.590759e+01'))
--實際應用
update waterqualitytemp set hg= convert(decimal(19,5),convert(float,hg)) where hg like '%e%'
----------------實際資料完整操作-----------------------------------------------
--excel操作 全選,右鍵設定單元格格式,文字(考慮到大於小於符號)
--excel匯入資料庫,改名為temp
--temp資料插入waterquality (插入前 temp加id列,設定主鍵和自增長。 waterquality的id列暫時取消自增長,注意事後改回來)
--insert into waterquality select * from [dbo].temp
-- 科學計數法 轉標準值
--測試案例
--select cast(cast('+1.590759e+01' as float) as decimal(19,5))
--實際應用
--update waterquality set hg= cast(cast(hg as float) as decimal(19,5)) where hg like '%e%'
--檢視結果
--select * from waterquality
-- 另一種方法 update waterqualitytemp set hg= convert(decimal(19,5),convert(float,hg)) where hg like '%e%'
--測試案例
--select convert(decimal(19,5),convert(float,'+1.590759e+01'))
--實際應用
--insert into waterqualitytemp select * from [dbo].temp
--select * from waterqualitytemp
--update waterqualitytemp set hg= convert(decimal(19,5),convert(float,hg)) where hg like '%e%'
樹立目標,保持活力,gogogo!
科學計數法
在做專案時發現乙個比較頭痛的問題,輸入法輸入金額android inputtype numberdecimal 控制項是可以輸入000.123的,為了獲取正確的輸入值可以使用下面方法,當輸入的資料很長時也不會被用科學計數法顯示 string str 000.123 bigdecimal bigdec...
科學計數法 20
時間限制 1000 ms 記憶體限制 32768 kb 長度限制 100 kb 判斷程式 standard 來自 小小 現以科學計數法的格式給出實數a,請編寫程式按普通數字表示法輸出a,並保證所有有效位都被保留。每個輸入包含1個測試用例,即乙個以科學計數法表示的實數a。該數字的儲存長度不超過9999...
科學計數法 PAT
科學計數法是科學家用來表示很大或很小的數字的一種方便的方法,其滿足正規表示式 1 9 0 9 e 0 9 即數字的整數部分只有 1 位,小數部分至少有 1 位,該數字及其指數部分的正負號即使對正數也必定明確給出。現以科學計數法的格式給出實數 a,請編寫程式按普通數字表示法輸出 a,並保證所有有效位都...