Learn about options for SQL Server currency output and most notably the different options the FORMAT function provides for money.
I had a requirement to produce a formatted currency string from within SQL server. I was able to build this scalar-valued function to meet the requirement.
SQL SELECTTOP (5) CurrencyRateID, EndOfDayRate,FORMAT(EndOfDayRate,'N','en-us')AS'Numeric Format',FORMAT(EndOfDayRate,'G','en-us')AS'General Format',FORMAT(EndOfDayRate,'C','en-us')AS'Currency Format'FROMSales.CurrencyRateORDERBYCurrencyRateID; ...
SQL SELECTTOP (5) CurrencyRateID, EndOfDayRate,FORMAT(EndOfDayRate,'N','en-us')AS'Numeric Format',FORMAT(EndOfDayRate,'G','en-us')AS'General Format',FORMAT(EndOfDayRate,'C','en-us')AS'Currency Format'FROMSales.CurrencyRateORDERBYCurrencyRateID; ...
SQL SELECTTOP (5) CurrencyRateID, EndOfDayRate,FORMAT(EndOfDayRate,'N','en-us')AS'Numeric Format',FORMAT(EndOfDayRate,'G','en-us')AS'General Format',FORMAT(EndOfDayRate,'C','en-us')AS'Currency Format'FROMSales.CurrencyRateORDERBYCurrencyRateID; ...
Convert Numbers/Currency to Words Convert nvarchar to date in format yyyy/mm? Convert nvarchar to decimal Convert one column of comma delimited data to multiple columns - dynamic (without using Pivot?) Convert rows to columns without aggregation Convert SQL datetime to Excel datetime convert sql va...
After you add the table to your report, you use SQL Server Data Tools (SSDT) to format the date field, currency field, and the column headers in the Sales Orders report. In this tutorial, you: Format the date field to display only the date. ...
NUMBER FORMAT Using FORMAT Function in SQL Server One can format numbers according to the culture using the Format function. DECLARE @Price AS INT SET @Price = '750000' SELECT FORMAT (@Price, 'N', 'en-us') as [US Currency] ,FORMAT (@Price, 'N', 'de-DE') as [Euro Currency] ...
SQL Copy SELECT TOP(5) CurrencyRateID, EndOfDayRate ,FORMAT(EndOfDayRate, 'N', 'en-us') AS 'Numeric Format' ,FORMAT(EndOfDayRate, 'G', 'en-us') AS 'General Format' ,FORMAT(EndOfDayRate, 'C', 'en-us') AS 'Currency Format' FROM Sales.CurrencyRate ORDER BY CurrencyRateID; ...
SQL SELECTTOP (5) CurrencyRateID, EndOfDayRate,FORMAT(EndOfDayRate,'N','en-us')AS'Numeric Format',FORMAT(EndOfDayRate,'G','en-us')AS'General Format',FORMAT(EndOfDayRate,'C','en-us')AS'Currency Format'FROMSales.CurrencyRateORDERBYCurrencyRateID; ...