Returns the character equivalent of the specified number, and pads the output with a character or numeric to the specified length.
str(approx_numeric[, length [, decimal]])
When you specify a character or numeric as a literal string, the character or numeric is used as padding for the field. When you specify a numeric value, sets the number of decimal places. The default is 0. When decimal is not set, the field is padded with blanks to the value specified by length.
select str(5,10,'0')
---------------- 0000000005
select str(5,10,5)
---------------- 5.00000
select str(12.34500,16,'_')
---------------- ________12.34500
select str(12.34500e,16)
---------------- 12
select str(12.34500e,16,7)
---------------- 12.3450000
select str(convert(numeric(10,2),12.34500e),16,'-')
---------------- -----------12.35
select str(convert(numeric(10,8),12.34500e),16,'-')
---------------- -----12.34500000
select str(123.456, 2, 4)
-- **
If approx_numeric is NULL, returns NULL.
See also Transact-SQL Users Guide.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute str.