码迷,mamicode.com
首页 > 其他好文 > 详细

str 函数 将小数转换为varchar类型

时间:2015-10-26 13:42:38      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

When you want to convert from float or real to character data, using the STR string function is usually more useful than CAST( ). This is because STR enables more control over formatting.

 

Syntax

STR ( float_expression [ , length [ , decimal ] ] )

Arguments                                               

float_expression                               

Is an expression of approximate numeric (float) data type with a decimal point.                

length                               

Is the total length. This includes decimal point, sign, digits, and spaces. The default is 10.

decimal                               

Is the number of places to the right of the decimal point. decimal must be less than or equal to 16. If decimal is more than 16 then the result is truncated to sixteen places to the right of the decimal point.

Return Type
  Varchar,
  To convert to Unicode data, use STR inside a CONVERT or CAST conversion function
示例
SELECT STR(123.45, 6, 1);

结果是 123.5,类型是Varchar

str 函数 将小数转换为varchar类型

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/4910852.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!