str

Returns the character equivalent of the specified number, and pads the output with a character or numeric to the specified length.

Syntax

str(approx_numeric[, length [, decimal]])

Parameters

Examples

Usage

length and decimal are optional, but if used, must be positive integers. str rounds the decimal portion of the number so that the results fit within the specified length. The length should be long enough to accommodate the decimal point and, if the number is negative, the number’s sign. The decimal portion of the result is rounded to fit within the specified length. If the integer portion of the number does not fit within the length, however, str returns a row of asterisks of the specified length. For example:
select str(123.456, 2, 4) 
-- 
** 

If approx_numeric is NULL, returns NULL.

See also Transact-SQL Users Guide.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute str.

Related reference
abs
ceiling
floor
round
sign