เจอปัญหาการแปลง datatype จาก float ไปเป็น varchar ข้อมูลจะอยู่ในรูป 1.29913e+006
วิธีแก้
Wrap your float within the str() function which, when given only one parameter, does have the side effect of dropping off everything to the right of the decimal point.
Problem:
select cast(cast(1234567890.01 as float) as varchar)
1.23457e+009
Answer without decimal:
select str(cast(1234567890.01 as float))
1234567890
Answer with decimal:
select str(cast(1234567890.01 as float),13,2)
1234567890.01
ที่มา http://stackoverflow.com/
Advertisement