If you are looking for a "true" Currency format, similar to what can be achieved via the FORMAT function that started in SQL Server 2012, then you can achieve the exact same functionality via SQLCLR. You can either code the simple .ToString("C" [, optional culture info]) yourself, or you can download the SQL# library (which I wrote, but this function is in the Free version) and use it just like the T-SQL FORMAT function.

For example:

SELECT SQL#.Math_FormatDecimal(123.456, N'C', N'en-us');

Output:

$123.46

SELECT SQL#.Math_FormatDecimal(123.456, N'C', N'fr-fr');

Output:

123,46 €

This approach works in SQL Server 2005 / 2008 / 2008 R2. And, if / when you do upgrade to a newer version of SQL Server, you have the option of easily switching to the native T-SQL function by doing nothing more than changing the name SQL#.Math_FormatDecimal to be just FORMAT.

Putting this into the context of the query from the original question:

SELECT SQL#.Math_FormatDecimal(COALESCE(SUM(SUBTOTAL),0), N'C', N'en-us') AS [Total]
FROM dbo.SALESORD_HDR 
where ORDERDATE = datediff(d,0,getdate()) 
and STATUS NOT IN (3,6)

EDIT:

OR, since it seems that only en-us format is desired, there is a short-cut that is just too easy: Converting from either the MONEY or SMALLMONEY datatypes using the CONVERT function has a "style" for en-us minus the currency symbol, but that is easy enough to add:

SELECT '$' + CONVERT(VARCHAR(50),
                CONVERT(MONEY, COALESCE(SUM(SUBTOTAL), 0)),
                1) AS [Total]
FROM dbo.SALESORD_HDR 
where ORDERDATE = datediff(d,0,getdate()) 
and STATUS NOT IN (3,6)

Since the source datatype of the SUBTOTAL field is FLOAT, it first needs to be converted to MONEY and then converted to VARCHAR. But, the optional "style" is one reason I prefer CONVERT over CAST.

Answer from Solomon Rutzky on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › format-transact-sql
FORMAT (Transact-SQL) - SQL Server | Microsoft Learn
CurrencyRateID EndOfDayRate Numeric Format General Format Currency Format -------------- ------------ -------------- -------------- --------------- 1 1.0002 1,00 1,0002 1,00 € 2 1.55 1,55 1,5500 1,55 € 3 1.9419 1,94 1,9419 1,94 € 4 1.4683 1,47 1,4683 1,47 € 5 8.2784 8,28 8,2784 8,28 €
Top answer
1 of 2
17

If you are looking for a "true" Currency format, similar to what can be achieved via the FORMAT function that started in SQL Server 2012, then you can achieve the exact same functionality via SQLCLR. You can either code the simple .ToString("C" [, optional culture info]) yourself, or you can download the SQL# library (which I wrote, but this function is in the Free version) and use it just like the T-SQL FORMAT function.

For example:

SELECT SQL#.Math_FormatDecimal(123.456, N'C', N'en-us');

Output:

$123.46

SELECT SQL#.Math_FormatDecimal(123.456, N'C', N'fr-fr');

Output:

123,46 €

This approach works in SQL Server 2005 / 2008 / 2008 R2. And, if / when you do upgrade to a newer version of SQL Server, you have the option of easily switching to the native T-SQL function by doing nothing more than changing the name SQL#.Math_FormatDecimal to be just FORMAT.

Putting this into the context of the query from the original question:

SELECT SQL#.Math_FormatDecimal(COALESCE(SUM(SUBTOTAL),0), N'C', N'en-us') AS [Total]
FROM dbo.SALESORD_HDR 
where ORDERDATE = datediff(d,0,getdate()) 
and STATUS NOT IN (3,6)

EDIT:

OR, since it seems that only en-us format is desired, there is a short-cut that is just too easy: Converting from either the MONEY or SMALLMONEY datatypes using the CONVERT function has a "style" for en-us minus the currency symbol, but that is easy enough to add:

SELECT '$' + CONVERT(VARCHAR(50),
                CONVERT(MONEY, COALESCE(SUM(SUBTOTAL), 0)),
                1) AS [Total]
FROM dbo.SALESORD_HDR 
where ORDERDATE = datediff(d,0,getdate()) 
and STATUS NOT IN (3,6)

Since the source datatype of the SUBTOTAL field is FLOAT, it first needs to be converted to MONEY and then converted to VARCHAR. But, the optional "style" is one reason I prefer CONVERT over CAST.

2 of 2
12

Here's a suggestion of the syntax to use to future-proof the search query.

select format(123.56789,'C2','en-US')  --$123.57 ;
select format(123.56789,'C3','en-US') --$123.568;
select format(123.56789,'C0','en-US') --$124
🌐
MSSQLTips
mssqltips.com › home › sql format currency code examples
SQL Format Currency Code Examples
December 30, 2024 - You can change the currency format using the SQL Server FORMAT function. This function allows you to format currency output.
🌐
7-Zip Documentation
documentation.help › acdata › ac_8_con_03_5c69.htm
Using Monetary Data - Accessing and Changing Relational Data Documentation
Currency or monetary data does not need to be enclosed in single quotation marks ('). However, the monetary data value must be preceded by the appropriate currency symbol. For example, to specify 100 English pounds, use £100. money and smallmoney are limited to four decimal points.
🌐
Sisense
sisense.com › home › blog › how to format numbers as currency in postgres, mysql and redshift
How to format numbers as currency in Postgres, MySQL and Redshift
May 8, 2023 - We’ll use the to_char function to specify an exact format string: select date(created_at), to_char(sum(price), 'FM$999,999,999,990D00') from orders group by 1 ... The commas separate the thousands, millions, etc.
🌐
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
🌐
Ask LibreOffice
ask.libreoffice.org › english
How to determine the format of a field in a table using sql? - English - Ask LibreOffice
July 24, 2017 - I am attempting to create a table using sql. I want the “dollars” field to show up as currency in this format: $0.00. Using the the following command I can only get the format without the dollar sign. CREATE TABLE “mytable3” (“id” INTEGER PRIMARY KEY, “dollars” NUMERIC (10,2))
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › format-sql-function
FORMAT() SQL FUNCTION | DataCamp
October 12, 2022 - We can also conveniently format numeric values into currencies. SELECT FORMAT(amount, 'c', culture) -- replace format with what is shown in the table below. FORMAT() works in SQL Server (starting with 2012), Azure SQL Database. FORMAT() also works in PostgreSQL, but behaves differently.
🌐
TechRepublic
techrepublic.com › home › displaying money values in currency format in sql
Displaying money values in currency format in SQL - TechRepublic
June 8, 2007 - Most of the time, your solution to this problem lies in client code rather than SQL code. However, I recognize that there are some situations in which it is best handled in server code. For example, Access, VB, and .NET offer the Format() function, which handles this problem nicely.
🌐
Wikipedia
en.wikipedia.org › wiki › ISO › IEC_8859-1
ISO/IEC 8859-1 - Wikipedia
4 weeks ago - Only three superscript digits have been encoded: ² at 0xB2, ³ at 0xB3, and ¹ at 0xB9, lacking the superscript digit 0 and digits 4–9. Additionally, none of the subscript digits have been encoded.
🌐
Red Gate Software
red-gate.com › home › a sql-based universal currency formatter
A SQL-Based Universal Currency Formatter - Simple Talk
August 16, 2021 - Now that we’ve identified a basic algorithm for our formatting, we shall construct a Table Valued Function (TVF) that utilizes this along with some final formatting of the result to include things like the currency symbol and the appropriate decimal point symbol. Note that we have changed the type of our OutputResult to NVARCHAR because our currency symbols are mostly UNICODE characters (up to 4). We also included the OPTION(MAXDOP 1) to avoid SQL parallelizing the query, which although unlikely could have a negative impact on the results, as the rows must be processed in a serial fashion.
🌐
OpenTelemetry
opentelemetry.io › docs › specs › otlp
OTLP Specification 1.10.0 | OpenTelemetry
OTLP/HTTP uses Protobuf payloads encoded either in binary format or in JSON format.
🌐
Oracle
docs.oracle.com › en › cloud › paas › analytics-cloud › acpmr › format-numbers-dates-and-currencies.html
Format Numbers, Dates, and Currencies
November 10, 2025 - To set the value dynamically, enter the tag name of the XML element that holds the ISO currency code. Note that an element that contains the currency code must be present in the data. At runtime, the Amount_Field is formatted according to the format you set up for the currency code in the report ...
🌐
Reddit
reddit.com › r/learnprogramming › [sql] how can i properly format this output for currency?
r/learnprogramming on Reddit: [SQL] how can i properly format this output for currency?
April 12, 2021 - SQL> SELECT b.title, CONCAT('$', ROUND(oi.paideach * oi.quantity - b.cost * oi.quantity, 2)) "Profit" 2 FROM books b, orderitems oi 3 WHERE b.isbn = oi.isbn 4 AND oi.order# = 1002; TITLE Profit ------------------------------ ----------------------------------------- DATABASE IMPLEMENTATION $49.1 SQL> i dont want to just CONCAT another 0 onto the end, i want to format it so it properly displays the currency with 2 decimal places, regardless of value.
🌐
Snowflake Documentation
docs.snowflake.com › en › sql-reference › sql-format-models
SQL format models | Snowflake Documentation
The digit group separator , (comma) or G results in the corresponding group separator character being printed if the number is big enough so the digits are on the both sides of group separator. An example of a format model useful for printing currency sums would be 999,999.00.
🌐
SQL Skull
sqlskull.com › home › how to display currency symbol in sql sever
How to display currency symbol in SQL Sever - SQL BI Tutorials
August 27, 2023 - Sometimes, we are asked to display a currency symbol along with the amount in query result set, It becomes challenge to displaying a currency symbol with amount. It can be done using FORMAT Function : FORMAT ( value, format [, culture ] ) The ...
🌐
Experts Exchange
experts-exchange.com › questions › 20127935 › Formatting-currency-with-SQL-in-Oracle.html
Solved: Formatting currency with SQL in Oracle | Experts Exchange
May 31, 2001 - ----- 280,833,351,405,805.26 GSM521D5:TSARADA> Add as many 9s as you need depending upon the digits in the return value, it doesn't matter if there are more 9s in the format mask.
🌐
Masud Ahmed
masudprogrammer.wordpress.com › 2016 › 07 › 19 › sql-sql-server-format-decimal-places-with-commas
SQL: SQL Server format money or decimal places with commas | Masud Ahmed
September 21, 2016 - Convert to money then convert to varchar with formatting option 1: SELECT CONVERT(varchar, CAST(1112 AS money), 1)
🌐
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 - In SQL, the currency is a common data type used to represent monetary values. Currency values typically include a currency symbol, such as “$” or “€”, and a decimal value representing the amount.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai