Format number with space as thousand separator

Kristoffer Jälén

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. Example: 123363.249999 should be displayed as 123 363,25.

I've tried:

SELECT REPLACE(CONVERT(varchar, CONVERT(money, 123363.249999), 1), '.00', '')

But that results in 123,363.25. I'm looking for nicer solution than just replacing comma with space and dot with comma. It would be nice to set the locale in the query.

Joe Stefanelli

For SQL Server 2008, I think your best bet for a "nicer" solution within SQL Server would be to write a custom CLR function to handle the formatting based on region/locale.

For SQL Server 2012 or later, the FORMAT function has been introduced.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Format number with space as thousand separator

From Dev

String Number format with "/" for thousand separator

From Dev

How to format number with "." as thousand separator, and "," as decimal separator?

From Dev

ionic +number format trouble based on the thousand separator

From Dev

Format integer number with . as thousand separator and no decimals

From Dev

Set standard number format with thousand separator, 2 decimals and minus sign for negative numbers using VBA?

From Dev

d3.format thousand separator on variables?

From Dev

Format a bootstrap table with dollar sign and thousand separator

From Dev

ExtJS 6 thousand separator in number field

From Dev

Is it possible to print a number formatted with thousand separator in Rust?

From Dev

Adding thousand separator while printing a number

From Dev

How to parse two space-delimited numbers with thousand separator?

From Dev

Add Thousand separator to any number even if it contains special characters

From Dev

remove thousand separator of number in CSV (batch command, using JREPL)

From Dev

Add Thousand separator to any number even if it contains special characters

From Dev

How to format a number with spanish thousand grouping in python?

From Dev

How to format a number with spanish thousand grouping in python?

From Dev

Thousand Separator in DBGrid

From Dev

Devexpress XRtableCell thousand separator?

From Dev

Thousand separator in awk

From Dev

Add space separator to number in input box

From Dev

Space separator INSTEAD of a comma - large number outputs

From Dev

Space in number format for xsl

From Dev

Format a number to always have a sign and decimal separator

From Dev

Format BigDecimal or Number without Decimal Separator

From Dev

Number Format with Thousands Separator and Decimal if Necessary

From Dev

Format BigDecimal or Number without Decimal Separator

From Dev

Format a number to display a comma when larger than a thousand

From Dev

How to format a number as 2.5K if a thousand in PHP? Like Facebook

Related Related

  1. 1

    Format number with space as thousand separator

  2. 2

    String Number format with "/" for thousand separator

  3. 3

    How to format number with "." as thousand separator, and "," as decimal separator?

  4. 4

    ionic +number format trouble based on the thousand separator

  5. 5

    Format integer number with . as thousand separator and no decimals

  6. 6

    Set standard number format with thousand separator, 2 decimals and minus sign for negative numbers using VBA?

  7. 7

    d3.format thousand separator on variables?

  8. 8

    Format a bootstrap table with dollar sign and thousand separator

  9. 9

    ExtJS 6 thousand separator in number field

  10. 10

    Is it possible to print a number formatted with thousand separator in Rust?

  11. 11

    Adding thousand separator while printing a number

  12. 12

    How to parse two space-delimited numbers with thousand separator?

  13. 13

    Add Thousand separator to any number even if it contains special characters

  14. 14

    remove thousand separator of number in CSV (batch command, using JREPL)

  15. 15

    Add Thousand separator to any number even if it contains special characters

  16. 16

    How to format a number with spanish thousand grouping in python?

  17. 17

    How to format a number with spanish thousand grouping in python?

  18. 18

    Thousand Separator in DBGrid

  19. 19

    Devexpress XRtableCell thousand separator?

  20. 20

    Thousand separator in awk

  21. 21

    Add space separator to number in input box

  22. 22

    Space separator INSTEAD of a comma - large number outputs

  23. 23

    Space in number format for xsl

  24. 24

    Format a number to always have a sign and decimal separator

  25. 25

    Format BigDecimal or Number without Decimal Separator

  26. 26

    Number Format with Thousands Separator and Decimal if Necessary

  27. 27

    Format BigDecimal or Number without Decimal Separator

  28. 28

    Format a number to display a comma when larger than a thousand

  29. 29

    How to format a number as 2.5K if a thousand in PHP? Like Facebook

HotTag

Archive