SQL零星技術點:SQL中轉換money類型數值轉換為字符串問題


--SQL中轉換money類型數值轉換為字符串問題,直接轉換就轉為兩位了,所以需要做一下處理。具體請看下述sql實例。


1
create table #test(price money) 2 3 insert into #test values (45.2525) 4 5 6 7 select cast(price as varchar(50)) from #test   --輸出45.25 四位小數只有兩位了 8 select convert(VARCHAR,price) from #test      --輸出45.25  四位小數只有兩位了 9 10 select convert(VARCHAR,45.2525)   --輸出為45.2525 四位小數 11 12 13 14 select cast(CAST(price AS DECIMAL(20,4)) as varchar(50)) from #test   --輸出為45.2525 四位小數 15 select convert(VARCHAR,convert(DECIMAL(20,4),price)) from #test   --輸出為45.2525 四位小數 16 17 DROP TABLE #test

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM