You can try
SELECT RIGHT('00000' + CAST(number AS NVARCHAR), 5)
The result will be a string, not a number type.
Answer from bobs on Stack OverflowMSSQLTips
mssqltips.com › home › sql format number with cast, convert and more
SQL Format Number with CAST, CONVERT and more
October 31, 2025 - Daniel also regularly speaks at SQL Servers conferences and blogs. MSSQLTips Awards: Author of the Year Contender – 2015-2018, 2022, 2023 | Champion (100+ tips) – 2018 ... SELECT FORMAT(5634.6334, ‘N’, ‘en-us’) AS ‘Number’ returns 5,634.63 (and not 5,634.6334) because the formatting string precision defaults to a scale of two.
W3Schools
w3schools.com › sql › func_sqlserver_format.asp
SQL Server FORMAT() Function
The FORMAT() function formats a value with the specified format (and an optional culture in SQL Server 2017). Use the FORMAT() function to format date/time values and number values.
Videos
05:58
SQL SERVER||How to Format column VARCHAR data type to INT? - YouTube
13:40
Prettify Your SQL Outputs with the FORMAT Function - YouTube
03:51
Number Formatting in MySQL - #SQL - YouTube
06:16
SQL Phone Number Format - YouTube
02:42
How to Format Numeric Values with Commas in SQL - YouTube
05:23
SQL FORMAT() Function - YouTube
Top answer 1 of 3
21
You can try
SELECT RIGHT('00000' + CAST(number AS NVARCHAR), 5)
The result will be a string, not a number type.
2 of 3
5
If you're on SQL Server 2012 or later, you can also use the FORMAT function:
SELECT FORMAT(1, '00000') AS PaddedNumber
It nicely formats all kinds of stuff ...
Database Guide
database.guide › how-to-format-numbers-in-sql-server
How to Format Numbers in SQL Server
May 3, 2018 - A format string defines how the output should be formatted. ... In this case, I used N as the second argument. This is the standard numeric format specifier for Number. This particular format specifier (N) results in the output being formatted with integral and decimal digits, group separators, ...
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › format-transact-sql
FORMAT (Transact-SQL) - SQL Server | Microsoft Learn
The following example shows how to format large numbers with comma separators. SELECT FORMAT(1234567.89, 'N0') AS FormattedNumber; Here's the result set. ... This example uses the N format specifier. The N specifier is used for numeric values, and the number of decimal places can be adjusted by changing the format string (for example, N2 for two decimal places).
EDUCBA
educba.com › home › data science › data science tutorials › sql tutorial › sql to number format
SQL to Number Format | Conversion from a String Type to a Numeric Type
April 3, 2023 - ROUND: Rounds a numeric value to the specified length or precision. TRUNCATE: Removes decimal places from a numeric value. PARSE: You can convert a string representation of a number to a numeric value.
Call +917738666252
Address Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
YouTube
youtube.com › watch
Converting numbers to strings in SQL Server: STR and FORMAT functions - YouTube
In this video, we will be looking at how to convert numbers to strings in SQL Server.My SQL Server Udemy courses are:70-461, 70-761 Querying Microsoft SQL Se...
Published August 4, 2021
Sqlmatters
sqlmatters.com › Articles › Formatting a number with thousand separators.aspx
Formatting a number with thousand separators - SQLMatters
You might prefer to encapsulate this into a User Defined Function (UDF), though if performance is an issue a CLR should perform better. I will finish by pointing out that formatting numbers is something that should really be left to the presentation layer (e.g. Reporting Services or Excel) rather than SQL, which is probably why Microsoft hasn’t included the functionality to do this.
Top answer 1 of 16
343
In SQL Server 2012 and higher, this will format a number with commas:
select format([Number], 'N0')
You can also change 0 to the number of decimal places you want.
2 of 16
272
While I agree with everyone, including the OP, who says that formatting should be done in the presentation layer, this formatting can be accomplished in T-SQL by casting to money and then converting to varchar. This does include trailing decimals, though, that could be looped off with SUBSTRING.
SELECT CONVERT(varchar, CAST(987654321 AS money), 1)
W3Schools
w3schools.com › sql › func_mysql_format.asp
MySQL FORMAT() Function
String Functions: Asc Chr Concat with & CurDir Format InStr InstrRev LCase Left Len LTrim Mid Replace Right RTrim Space Split Str StrComp StrConv StrReverse Trim UCase Numeric Functions: Abs Atn Avg Cos Count Exp Fix Format Int Max Min Randomize Rnd Round Sgn Sqr Sum Val Date Functions: Date DateAdd DateDiff DatePart DateSerial DateValue Day Format Hour Minute Month MonthName Now Second Time TimeSerial TimeValue Weekday WeekdayName Year Other Functions: CurrentUser Environ IsDate IsNull IsNumeric SQL Quick Ref
TechOnTheNet
techonthenet.com › oracle › functions › to_number.php
Oracle / PLSQL: TO_NUMBER Function
March 30, 2019 - Since the format_mask and nls_language parameters are optional, you can simply convert a text string to a numeric value as follows: TO_NUMBER('1210.73') Result: 1210.73 · Share on: SQL · Oracle / PLSQL · SQL Server · MySQL · MariaDB · PostgreSQL · SQLite · Excel ·
T-SQL Tutorial
tsql.info › sql › how-to-convert-string-to-numeric.php
How to convert String to Numeric in sql
How to convert String to Numeric in sql with cast and convert functions. Examples of coversion.
Snowflake Documentation
docs.snowflake.com › en › sql-reference › sql-format-models
SQL format models - Source: Snowflake Documentation
In Snowflake, SQL format models (that is, literals containing format strings) are used to specify how numeric values are converted to text strings and vice versa. As such, they can be specified as arguments in the TO_CHAR , TO_VARCHAR and TO_DECIMAL , TO_NUMBER , TO_NUMERIC conversion functions.
Oracle
docs.oracle.com › en › database › oracle › oracle-database › 19 › sqlrf › TO_NUMBER.html
TO_NUMBER
November 12, 2025 - expr can be any expression that evaluates to a character string of type CHAR, VARCHAR2, NCHAR, or NVARCHAR2, a numeric value of type NUMBER, BINARY_FLOAT, or BINARY_DOUBLE, or null. If expr is NUMBER, then the function returns expr. If expr evaluates to null, then the function returns null. Otherwise, the function converts expr to a NUMBER value. If you specify an expr of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type, then you can optionally specify the format model fmt.