|
str()
The
string function
str()
returns a
character
which corresponds to the
value
(floating point) declared in the parameter "approx_numeric".
Syntax of the String Function str()
str ( approx_numeric [, length [, decimal] ] )
The parameters of the String Function str()
"approx_numeric"
The parameter "approx_numeric" can be a
column name,
variable
or
constant
and must be of one of the
datatypes
float,
real,
or
double precision
If the parameter "approx_numeric" has a value of
NULL,
then NULL will also be returned.
"length"
The parameter "length" is optional. It defines the number of characters to be returned.
This includes the decimal point of the floating point number and all digits before and after the decimal point. Default is 10.
"decimal"
The parameter "decimal" is optional. It defines the number of decimal digits to be returned. Default is 0.
Example for the String Function str()
select str(1234.56, 4)
go
-----
1234
Returns the first four digits as a
character-string.
select str(-1234.56, 4)
go
-----
-123
Returns the first four digits as a character-string.
select str(1234.56, 6, 2)
go
-----
1234.5
Returns the first six digits as a character-string.
See also:
ASE T-SQL - Aggregate Functions, ascii(), char(), char(n), charindex(), char_length(), compare(), difference(), lower(), ltrim(), patindex(), replicate(), reverse(), right(), rtrim(), sortkey(), soundex(), space(), String Functions, stuff(), substring(), to_unichar(), uhighsurr(), ulowsurr(), upper(), uscalar().
|