title: Microsoft Query in Excel - Casting types?
body: <p>I have an Excel workbook that has an external connection to a .csv file for a pivot table. One of the columns in the .csv - let's call it ID - has data such as '00000000000000101'. I have a simple <code>SELECT ID FROM DATA.csv</code> set up.</p>
  
  <p>In Microsoft Access, while importing the table, I can classify that field to be text before running the query on it. However, in my current situation, Excel/Microsoft Query is taking it in as int. I looked up the CAST function, and proceeded to try</p>
  
  <p><code>SELECT CAST(ID AS TEXT)</code> and 
  <code>SELECT CAST(ID AS CHAR(255))</code></p>
  
  <p>but both yielded me the error </p>
  
  <blockquote>
    <p>Incorrect column expression: 'CAST(ID AS xxx'.</p>
  </blockquote>
  
  <p>Am I using the function incorrectly? How should I approach this?</p>
  
  <p>If it is relevant, here is my connection string:</p>
  
  <pre><code>DBQ=C:\;Driver={Microsoft Access Text Driver (*.txt, *.csv)};DriverId=27;Extensions=txt,csv,tab,asc;FIL=text;MaxBufferSize=2048;MaxScanRows=25;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;
  </code></pre>