title: SQL Server formatting negative values from selected data
body: <p>I am new to stackoverflow but I do search it often.</p>
  
  <p>I am creating a report from data in which I have to format negative numbers like,</p>
  
  <pre><code>-00000010  (9 characters max)
  </code></pre>
  
  <p>I am getting this,
  000000-10</p>
  
  <p>This is what I am attempting now but I'm having issues. Any help would be greatly appreciated.</p>
  
  <pre><code>SELECT 'H' 
      + DG.BLOCK 
      + LEFT(DG.ZIP,5) 
      + RIGHT('000000000' 
      + CAST(CAST(SUM(DG.WP)AS INT) AS VARCHAR(9)),9) 
      + RIGHT('000000000' + CAST(CAST(SUM(DG.WE)AS INT) AS VARCHAR(9)),9)
      + RIGHT('000000000' + CAST(CAST(SUM(DG.EP)AS INT) AS VARCHAR(9)),9) 
      + RIGHT('000000000' + CAST(CAST(SUM(DG.EE)AS INT) AS VARCHAR(9)),9)
      + RIGHT('000000000' + CAST(CAST(COUNT(DGG.CLAIMCONTROL)AS INT) AS VARCHAR(9)),9)
      + RIGHT('000000000' + CAST(CAST(SUM(DGG.INC) AS INT) AS VARCHAR(9)),9)
      + RIGHT('000000000' + CAST(CAST(SUM(DGG.PAID)AS INT) AS VARCHAR(9)),9)
      + RIGHT('000000000' + CAST(CAST(SUM(DGG.ALAE) AS INT) AS VARCHAR(9)),9) 
  AS [H Record]
  FROM TABLE
  </code></pre>