title: How to get BCP to generate a Format File for importing fixed-width data into a SQL Server table?
body: <p>The bcp command that I am using:</p>
  
  <p><strong>bcp TableName format nul -c -f c:\folder\TargetFile.xml -x -S ServerName -T -q</strong></p>
  
  <p>I think I just need the fields to have a type of <em>xsi:type="CharFixed"</em> rather then <em>xsi:type="CharTerm"</em>.</p>
  
  <p>The xml that it creates which doesn't work for me: </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
   &lt;RECORD&gt;
    &lt;FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="24" COLLATION="SQL_Latin1_General_CP1_CI_AS"/&gt;
    &lt;FIELD ID="2" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="150" COLLATION="SQL_Latin1_General_CP1_CI_AS"/&gt;
    &lt;FIELD ID="3" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="150" COLLATION="SQL_Latin1_General_CP1_CI_AS"/&gt;
    &lt;FIELD ID="4" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="20" COLLATION="SQL_Latin1_General_CP1_CI_AS"/&gt;
    &lt;FIELD ID="5" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="12" COLLATION="SQL_Latin1_General_CP1_CI_AS"/&gt;
   &lt;/RECORD&gt;
   &lt;ROW&gt;
    &lt;COLUMN SOURCE="1" NAME="UID" xsi:type="SQLNCHAR"/&gt;
    &lt;COLUMN SOURCE="2" NAME="FNAME" xsi:type="SQLNCHAR"/&gt;
    &lt;COLUMN SOURCE="3" NAME="LNAME" xsi:type="SQLNCHAR"/&gt;
    &lt;COLUMN SOURCE="4" NAME="PHONE" xsi:type="SQLNCHAR"/&gt;
    &lt;COLUMN SOURCE="5" NAME="Target" xsi:type="SQLNCHAR"/&gt;
   &lt;/ROW&gt;
  &lt;/BCPFORMAT&gt;
  </code></pre>
  
  <p>What I actually need: (xsi:type="CharFixed")</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;RECORD&gt;
    &lt;FIELD ID="1" xsi:type="CharFixed" LENGTH="3"/&gt;
    &lt;FIELD ID="2" xsi:type="CharFixed" LENGTH="3"/&gt;
  &lt;/RECORD&gt;
  &lt;ROW&gt;
    &lt;COLUMN SOURCE="1" NAME="Field1" xsi:type="SQLCHAR" LENGTH="3"/&gt;
    &lt;COLUMN SOURCE="2" NAME="Field2" xsi:type="SQLCHAR" LENGTH="3"/&gt;
  &lt;/ROW&gt;
  &lt;/BCPFORMAT&gt;
  </code></pre>