title: How to created a fixed width ouput with sqlcmd
body: <p>The following executes in our SQL 2008 R2 environment and everything works well.  Vendor executes on  SQL Server 2012 and formatting changes.  </p>
  
  <p>For example a simple select  </p>
  
  <pre><code>Select '1',cast(RIGHT(replace(convert(varchar,[EMPL_EARNINGS].[PAY_PD_END_DT],112),'-',''),6) as CHAR(6)) 
  </code></pre>
  
  <p>I can't use <code>-W</code> because some fields are padded with spaces.  </p>
  
  <p>I select 3 different date fields with the same statement.<br>
  One is correct 6 characters wide, another is 8, and yet another is 9.  </p>
  
  <p>Batch file call is  <code>sqlcmd -S ServerName -i "c:\query\myquery.sql" -o "v:\Temp\myouput.dat" -h -1 -s""  -d"DBname"</code>.</p>