title: Passing spool file name to SQL script as a parameter from batch file - unexpected behaviour
body: <p>When I pass in a name for a spool file, I get an incorrect file name. For example, I double-click command.bat and enter 'TEST' (without quotes) at the prompt and hit enter. Script runs and queries that database properly, but my output file is 'TESTcsv.LST' (again without quotes). If I change the file name to a proper 'TEST.csv', I can see that the output is correct.</p>
  
  <p>command.bat:</p>
  
  <pre><code>@echo off
  SET /P name="Enter name: "
  sqlplus username/password @script.sql %name%
  </code></pre>
  
  <p>script.sql:</p>
  
  <pre><code>--A whole bunch of formatting code
  ...
  spool T:\&amp;1.csv
  SELECT * FROM tablename WHERE somecol='&amp;1';
  spool off
  exit
  </code></pre>
  
  <p>Furthermore, if I change the sqlscript to read:</p>
  
  <pre><code>spool T:\'&amp;1'.csv
  </code></pre>
  
  <p>My output file becomes 'TEST'.csv. When I leave out the single quotes, why does it delete the  '.' in the spool file name and append '.LST'?</p>
  
  <p>Note that the parameter being passed to the script is also being used in the query without any issues.</p>
  
  <p>I've also tried passing the arguments using sqlcmd utility, but no luck there, so I'd like to get this working without sqlcmd if possible. For now, I can rename the file, but it is a bit annoying to have to do that every time I need to run the script.</p>