Output number as text with four decimal places and commas in SQL Server 2008
Posted on 2009-04-28
I'm working on a view where I need to output a string containing numeric data.
The data is stored as a 'real' datatype, so it looks like
or a different number in the same data may look like
I need them both formatted the same for output . . .
in other words, I need four significant decimal places on the right and comma in the thousands position on the left. Formatting as Money doesn't work because it won't let you combine four decimal places with commas on the left as far as I can tell.
Any suggestions? All I can think to do is convert each number twice and combine the left side with the commas from one conversion with the decimal point and the four digits to the right.
Isn't there a way to do this without writing some horribly complex function? Any suggestions?