'How to avoid cutting off decimal places when using FORMAT( )

Lets say I have a number like 123456789.9876

I want to format it so that it displays as such 123,456,789.9876.

When I try SELECT FORMAT(123456789.9876, 'N'), I get the following result 123,456,789.99



Solution 1:[1]

UPDATE: After John Cappelletti pointed out in the comment. you should use

SELECT FORMAT(123456789.9876, '#,##0.#####')

I understand your pain. This is what I have done

SELECT FORMAT(123456789.9876, '###,###,###,###.#####')

db fiddle link

note that adding extra # do not pads with 0s. So if you need to do (24 precision and 8 scale) do like '#,###,###,###,###,###.########'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1