SELECT FORMAT(12345,'#,0.00');

SELECT FORMAT(TotalArea,'#,0.00') from table;

Reference: https://msdn.microsoft.com/en-us/library/ee634206(v=sql.105).aspx

Answer from dasiimwe on Stack Overflow
๐ŸŒ
Sqlmatters
sqlmatters.com โ€บ Articles โ€บ Formatting a number with thousand separators.aspx
Formatting a number with thousand separators - SQLMatters
Oracle SQL Plus makes this EXTREMELY easy with format number as 999,999,999,999. Once again, SQL Server developers assume that the only users of data are dot net developers, not including the DBAs who take care of all this data and only want/need a simple T-SQL output 90% of the time.
Discussions

SQL Thousand separator with round โ€“ SQLServerCentral Forums
SQL Thousand separator with round Forum โ€“ Learn more on SQLServerCentral More on sqlservercentral.com
๐ŸŒ sqlservercentral.com
December 3, 2013
sql server - Convert string numeric values with comma as decimal separator to NUMERIC(10, 2) - Database Administrators Stack Exchange
I have an SQL table of varchar columns which contain Greek formatted numbers (. as thousand separator and comma as decimal separator) ... (If you are using SQL Server 2012 or newer, please see @wBob's answer for a cleaner approach. More on dba.stackexchange.com
๐ŸŒ dba.stackexchange.com
October 14, 2015
sql - Format number with space as thousand separator - Stack Overflow
First: Yes I know number formatting shall not be done in data layer, but I'm working with an application I can't modify, nor can I format the result set in the application. I can only write a query. For a SQL Server 2008 query I want to use space as thousand separator and also round to two decimals. More on stackoverflow.com
๐ŸŒ stackoverflow.com
how to add commas as thousand separator for numbers stored as text โ€“ SQLServerCentral Forums
how to add commas as thousand separator for numbers stored as text Forum โ€“ Learn more on SQLServerCentral More on sqlservercentral.com
๐ŸŒ sqlservercentral.com
July 20, 2011
๐ŸŒ
SQL Server Guides
sqlserverguides.com โ€บ format-number-with-thousands-separator-in-sql-server
Format Number with Thousands Separator in SQL Server - SQL Server Guides
November 13, 2023 - In this SQL Server tutorial, you covered how to use the FORMAT() and CONVERT() functions to format the column numeric values with a thousand separator. Also used the CAST() function while formatting the number with a thousand separator.
๐ŸŒ
SQLServerCentral
sqlservercentral.com โ€บ forums โ€บ topic โ€บ sql-thousand-separator-with-round
SQL Thousand separator with round โ€“ SQLServerCentral Forums
December 3, 2013 - If you have to do it in SQL, here is one option for your consideration. It is not the be-all and end-all of formatting, just enough to get the job done in the few cases that there is no other way. This was code I wrote several years ago; it could be improved, but I don't currently have a need to do so. ... ---------------------------------------------------------------------------------------------------- ... Converts a number to a string.
Top answer
1 of 3
15

(If you are using SQL Server 2012 or newer, please see @wBob's answer for a cleaner approach. The approach outlined in my answer below is only required if you are using SQL Server 2008 R2 or older.)

You don't need (or want) the thousands' separator when converting to NUMERIC, regardless if it is comma, period, or space, so just get rid of them first. Then convert the comma into a period / decimal and you are done:

SELECT CONVERT(NUMERIC(10, 2), 
               REPLACE(
                       REPLACE('7.000,45', '.', ''),
                       ',', '.'
                      )
              ) AS [Converted];

Returns:

7000.45

For the sake of completeness, I should mention that I also tried:

  • SET LANGUAGE Greek;

  • Looking at various format styles for CONVERT, but nothing applies here.

  • The FORMAT function, but the input type must be a numeric or date/time/datetime value (that and it was introduced in SQL Server 2012, so not applicable to SQL Server 2008 R2 or older).

And nothing else seemed to work. I was hoping to find something more elegant than two REPLACE calls, but so far no such luck.


Also, just to mention, while not a pure T-SQL solution, this can also be accomplished via SQLCLR. And, there is a pre-done function that does this in the SQL# library (that I wrote) named String_TryParseToDecimal. This function is available in the Free version, and works in every version of SQL Server starting with SQL Server 2005:

SELECT SQL#.String_TryParseToDecimal('7.000,45', 'el-GR');

Returns:

7000.45000000000000000000
2 of 3
14

What version of SQL Server are you using? From SQL Server 2012 onwards you can use TRY_PARSE with its USING culture argument. You can also use PARSE, the difference being PARSE will fail if the conversion fails and TRY_PARSE will return a NULL, eg

DECLARE @t TABLE ( x VARCHAR(10) )

INSERT INTO @t
VALUES ( '7.000,45' ), ( 'xxx' )

SELECT x, 
    TRY_PARSE( x AS NUMERIC(10,2) USING 'El-GR' ) x
FROM @t

HTH

๐ŸŒ
MSSQLTips
mssqltips.com โ€บ home โ€บ sql server format dates, numbers and sql server agent dates
SQL Server FORMAT Dates, Numbers and SQL Server Agent Dates
October 28, 2021 - In T-SQL, we have a date function, ... requirements on how a numeric data type is displayed, such as a thousand separator every 3 digits, a percentage sign, a currency prefix or a different format when minus value is ...
Find elsewhere
๐ŸŒ
Database Guide
database.guide โ€บ how-to-format-numbers-with-commas-in-sql-server
How to Format Numbers with Commas in SQL Server
October 27, 2021 - Itโ€™s also possible to use custom format specifiers to construct your own custom format strings. For example, the # character is a digit placeholder, the 0 is a zero placeholder, the comma (,) is a placeholder for the group separator, and the full stop (.) is a placeholder for the decimal ... This is true regardless of the locale being used โ€“ SQL Server will work out which characters to use for the group and decimal separators based on the current locale.
๐ŸŒ
Database Guide
database.guide โ€บ 2-ways-to-format-numbers-with-thousand-separators-and-decimals-in-sql-server
2 Ways to Format Numbers with Thousand Separators and Decimals in SQL Server
August 20, 2025 - Hereโ€™s a quick table that shows the difference between the two options: If you just want a quick, modern, and flexible way, use FORMAT(@Number, 'N2'). If you need speed and donโ€™t care about cultures, casting to money with CONVERT() is faster. Formatting numbers in SQL Server is a small ...
๐ŸŒ
Experts Exchange
experts-exchange.com โ€บ questions โ€บ 29079083 โ€บ T-SQL-Number-format-with-no-decimals.html
Solved: T-SQL Number format with no decimals | Experts Exchange
January 18, 2018 - Execute a query in SQL Server management studio using format() Does that work? Then the problem is somewhere on the way from Access to Excel, perhaps. Even if the number is interpreted as string (as it is a string) it can be sorted, as alphabetical sorting of a number is the same as numerical sorting, given the thousands separators are at the same places.
๐ŸŒ
ASPSnippets
aspsnippets.com โ€บ questions โ€บ 567607 โ€บ Format-Apply-thousand-separator-in-SQL-Server
Format Apply thousand separator in SQL Server
July 20, 2011 - DECLARE @Test AS TABLE(Id INT, Name VARCHAR(5), Salary VARCHAR(15)) INSERT INTO @test VALUES(1,'a','40000444.34') INSERT INTO @test VALUES(2,'b','310000') INSERT INTO @test VALUES(3,'c','400000') INSERT INTO @test VALUES(3,'a','500000') SELECT Id,Name, CASE WHEN Name = 'a' THEN FORMAT(CAST(Salary AS MONEY), '###,###,###.##', 'en-in') ELSE Salary END 'Salary' FROM @Test
๐ŸŒ
SQLServerCentral
sqlservercentral.com โ€บ forums โ€บ topic โ€บ format-number-thousands-separator-with-point
Format number thousands separator with point โ€“ SQLServerCentral Forums
November 14, 2023 - I have this number in my database output result of query: ... Thanks in advance. You should probably be doing this in the presentation layer, rather than the database. ... Table '#testEnvironment'. Scan count 1, logical reads 2102, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. ... CPU time = 609 ms, elapsed time = 610 ms. ... Sorry, I've just noticed that you asked for dot separators not commas.
๐ŸŒ
Sqlpowered
sqlpowered.com โ€บ converting-string-values-with-thousands-separator-to-numeric-value
Converting string values with thousands separator to numeric value โ€“ SQLpowered.com
DECLARE @NumberInStr NVARCHAR(10) ... @NumberInStr) / 100 GO ยท This time we should be more careful because MONEY datatype understands both separators: dot and comma same time....
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ sql โ€บ t-sql โ€บ functions โ€บ format-transact-sql
FORMAT (Transact-SQL) - SQL Server | Microsoft Learn
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric SQL database in Microsoft Fabric ยท Returns a value formatted with the specified format and optional culture. Use the FORMAT function for locale-aware formatting of date/time and number values as strings.
๐ŸŒ
Narkive
microsoft.public.sqlserver.programming.narkive.com โ€บ Y5MyLiEp โ€บ formatting-numbers-in-sql
Formatting numbers in SQL
May 5, 2023 - Also, AFAIK the CONVERT function only supports comma as a thousands separator by default. In reality you should find it much easier to do the formatting in the client control or form that displays the data. ... Permalink My problem is that these values is displayed in a Word-document, and the program that collects these values and inserts them into word, is not available for formatting, and will not ever be available. So basically, I am stuck with formatting this in SQL-server...
๐ŸŒ
SQL Server Guides
sqlserverguides.com โ€บ sql-server-format-number-with-commas-without-decimal-places
SQL Server Format Number with Commas without Decimal Places - SQL Server Guides
April 21, 2009 - After the execution of the above query, it formats the number of the SalePrice column with commas which is also known as a thousand separator. For example, the Xbox Series X product sale price is 60,000 and this price or number is formatted with commas without decimal places. Here within the FORMAT() function, the โ€˜###,###,###โ€™ custom format specifier means separating the group of three digits with commas. The โ€˜#โ€™ symbol is a placeholder for the digit from zero to nine. The LEFT() function in SQL Server retrieves the leftmost characters from the strings and the LEN() function returns the number of characters of the given string value.
๐ŸŒ
Database Guide
database.guide โ€บ custom-numeric-format-strings-supported-by-format-in-sql-server
Custom Numeric Format Strings Supported by FORMAT() in SQL Server
July 2, 2019 - This article provides a reference for the custom numeric format specifiers that can be used when formatting numbers using the FORMAT() function in SQL Server.