STR()
The STR Transact-SQL function returns character data converted from numeric data.
Signature
STR ( float_expression [ , length [ , decimal ] ] )Parameters
- float_expression — An expression of approximate numeric (float) data type with a decimal point.
- length — The total length, including the decimal point, sign, digits, and spaces. The default is 10.
- decimal — The number of places to the right of the decimal point. *decimal* must be less than or equal to 16. If *decimal* is more than 16, the result is truncated to 16 places to the right of the decimal point.
Examples
SELECT STR(123.456, 8, 2) AS padded;padded
--------
123.46Run against SQL Server 16.0.4265.3 on 2026-09-13. This is the output we got, not the documentation’s.
Available on
- SQL Server 2017 and later
- Azure SQL Database
- Azure SQL Managed Instance
- Azure Synapse Analytics
- Analytics Platform System (PDW)
- Microsoft Fabric warehouse
- Fabric SQL database
Signature and description adapted from the Microsoft SQL documentation, used under the CC BY 4.0. SQL Server and Azure are trademarks of the Microsoft group of companies. This page is not affiliated with Microsoft.