Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

STR

Example

Convert a number into its string representation.

SELECT STR(185);

Definition and Usage

The STR() function converts a number into a string format.

Syntax

STR(numberlengthdecimals)

Parameter Values

Parameter

Description

Number

Required: Specifies the number that needs to be converted into a string format.

Length

Optional: Specifies the length of the resulting string. If not provided, the default value is 10.

decimal

Optional: Specifies the number of decimal places to display in the resulting string. If not provided, the default value is 0.

Technical Details

Works in:

 SQL Server (from 2008 onward), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse

More Examples

Example

Convert a numeric value into its string representation.

SELECT STR(185.5);

Example

Convert a numerical value into a string format.

SELECT STR(185.47662);