title: Getting column names with BCP queryout
body: <p>I need to BCP a table into a tab-delimited file, but I need the column names in the first record of the table.  Question 1:  Am I right that BCP does not have a switch for this?  Question 2:  If not, why?</p>
  
  <p>I tried to do the following: </p>
  
  <pre><code>BCP "declare @colnames varchar(max); select @colnames=coalesce (@colnames+char(9), '') 
  + Column_Name from db.information_Schema.columns where table_name='table1' order by 
  ordinal_position; select @colnames" queryout Table1_Columns.tsv -S?? -U?? -P?? -f** -e**
  </code></pre>
  
  <p>The format file looks like this:</p>
  
  <pre><code>9.0
  1
  1 SQLCHAR 0 100 "\r\n" 1 Column_Names SQL_Latin1_General_CP1_CI_AS
  </code></pre>
  
  <p>This gets me a file of the column names, then a second BCP command gets me a file of data, and I just DOS-copy the two together.  Question 3:  Am I clever or what?  Question 4:  Why doesn't it work?  I get the error:</p>
  
  <pre><code>SQLState = S1000, NativeError = 0
  Error = [Microsoft][SQL Native Client]Host-file columns may be skipped only when 
  copying into the Server
  </code></pre>