SQL Server/T-SQL/String Functions/STR
Содержание
- 1 Specifying an overall length greater than the length of the value, decimal point, and the decimal value, the result will be left-padded with spaces
- 2 STR(100.325,7)
- 3 STR(123. 4)
- 4 STR() Function: converts a numeric value to a string
- 5 STR() function right-fills the decimal value with zeros
- 6 STR: takes a numeric value and changes the data type to a char
Specifying an overall length greater than the length of the value, decimal point, and the decimal value, the result will be left-padded with spaces
1>
2> --Specifying an overall length greater than the length of the value, decimal point,
3> --and the decimal value, the result will be left-padded with spaces
4>
5> SELECT STR(1, 12, 4)
6> GO
------------
1.0000
(1 rows affected)
1>
2>
STR(100.325,7)
1> --the following will return 100 (note the 4 spaces):
2>
3> SELECT STR(100.325,7)
4> GO
-------
100
(1 rows affected)
1>
STR(123. 4)
1> SELECT STR(123.456789, 8, 4)
2> GO
--------
123.4568
(1 rows affected)
1>
2>
STR() Function: converts a numeric value to a string
1>
2> -- STR() Function: converts a numeric value to a string.
3>
4> SELECT STR(123.4, 8, 4)
5> GO
--------
123.4000
(1 rows affected)
1>
STR() function right-fills the decimal value with zeros
1>
2> -- STR() function right-fills the decimal value with zeros
3> SELECT STR(1, 6, 4)
4> GO
------
1.0000
(1 rows affected)
1>
2>
STR: takes a numeric value and changes the data type to a char
1> -- STR: takes a numeric value and changes the data type to a char.
2>
3> --STR(number_to_convert, length_of_string, [number_of_decimal_places])
4>
5> SELECT STR(100.325,7,2)
6> GO
-------
100.33
(1 rows affected)
1>