title: How to correct Select Spool in the BAT file
body: <p>I am writing a BAT file in the windows servers which will connect to the oracle and select output will be spooled to a file and output file will be placed to the network drive.</p>
  
  <p>I have done this via below steps:<br>
  1) Create a bat file to connect to the oracle and execute the file.</p>
  
  <pre><code>sqlplus UserName/Password@Hostname:1555/Service_Name @SQL_Script_to_execute
  copy generated_File_with_path network_location
  </code></pre>
  
  <p>2) Place the select query in the SQL script.</p>
  
  <pre><code>spool "path_to_the_saved_file";
  set define off;
  set heading off;
  set linesize 30000;
  select column_A||ColumnB|| columnC  from table;
  spool off;
  exit;
  </code></pre>
  
  <p>I am able to extract the query result in the output file but format is very incorrect.</p>
  
  <p>I am getting lots of extra space after end of last column and few blank rows.</p>
  
  <p>How Can I remove these extra spaces after the last column and in between blank lines?</p>
  
  <blockquote>
    <p>PS: I have done taken below steps till now <br></p>
    
    <ul>
    <li>Removed linesize in the SQL script so that extra spaces after the last column can be avoided but it make the output file much worse.
    Table rows were not coming in the single line.</li>
    <li>Added set pagesize 50000, it indeed resolved the issue but still few blank lines were still present in the
    file as total number of rows in the table is approx 70000.
    
    <ul>
    <li>I am already using query as select colA|| col B || colC from table to avoid space issue.</li>
    </ul></li>
    </ul>
  </blockquote>