title: How to get numbers arranged right to left in sql server SELECT statements
body: <p>When performing SELECT statements including number columns (prices, for example), the result always is left to right ordered, which reduces the readability. Therefore I'm searching a method to format the output of number columns right to left.</p>
  
  <p>I already tried to use something like</p>
  
  <pre><code>SELECT ... SPACE(15-LEN(A.Nummer))+A.Nummer ...
     FROM Artikel AS A ...
  </code></pre>
  
  <p>which gives close results, but depending on font not really. An alternative would be to replace 'SPACE()' with 'REPLICATE('_',...)', but I don't really like the underscores in output.</p>
  
  <p>Beside that this formula will crash on numbers with more digits than 15, therefore I searched for a way finding the maximum length of entries to make it more save like</p>
  
  <pre><code>SELECT ... SPACE(MAX(A.Nummer)-LEN(A.Nummer))+A.Nummer ...
     FROM Artikel AS A ...
  </code></pre>
  
  <p>but this does not work due to the aggregate character of the MAX-function.</p>
  
  <p>So, what's the best way to achieve the <i>right-justified</i> order for the number-columns?</p>
  
  <p>Thanks,
  Rainer</p>