STR (float_expression [, length [, decimal])
Parameters
Float_expression
An expression of the approximate number (float) data type with a decimal point.
Length
Total length. It includes the decimal point, symbol, number, and space. The default value is 10.
Decimal
The number of digits after the decimal point. Decimal must be less than or equal to 16. If the decimal value is greater than 16, the result is truncated to keep it
It has Sixteen digits after the decimal point.
Return type
Char
The STR function converts a number to a character. An optional parameter is used to specify the total length of the result (including the decimal point and the number of digits after the decimal point ).
The STR length and decimal parameter (if provided) should be a positive number. The default length is 10. When the default or decimal parameter is 0
, The number is rounded to an integer. The specified length should be greater than or equal to the length of the number before the decimal point plus the number symbol (if any ).
Degree.
In the following example, the float expression of 123.45 is converted to six characters in length and two decimal places.
Select STR (123.45, 6, 2 );
The following is the result set:
------
123.45
(1 row (s) affected)