title: Running SQL scripts as windows batch file
body: <p>I am using Oracle 11g and have an Oracle SQL query (not SQL+) as shown below </p>
  
  <pre><code>spool E:\teST\log.txt
  
  select username,account_status, created, default_tablespace 
  from dba_users where username='MMCANE';
  spool off
  
  exit;
  </code></pre>
  
  <p>which i intend to run as windows batch file and for that I created the .bat file with configuration as below </p>
  
  <pre><code>sqlplus *username*/*password*@*database* @E:\teST\Untitled.sql
  </code></pre>
  
  <p>Where <strong>Untitled.sql</strong> is the select query am running</p>
  
  <p><strong>1. Will I be able to run it as SQL and not as SQL Plus ?</strong></p>
  
  <p>Running the batch file generates the required output as a text file, but since am running it as sqlplus, am getting an unformatted output text file (see below)</p>
  
  <pre><code>   USERNAME ACCOUNT_STATUS                                                            
  ---------- --------------------------------  
  CREATED    
  --------------------------------------------------------------
  DEFAULT_TABLESPACE                                                                     
  --------------------------------------------------------------------------------
     MMCANE OPEN                                                              
  13-SEP-17
  USERS
  </code></pre>
  
  <p>as opposed to the script output (see below) that is generated by running the query in SQL developer itself</p>
  
  <pre><code>USERNAME             ACCOUNT_STATUS            CREATED                  DEFAULT_TABLESPACE             
  ------------------  ----------------------------- ------------------------- ----------------------- 
   MMCANE              OPEN                      13-SEP-17                 USERS  
  </code></pre>
  
  <p><strong>2. Is there a way to format it? If so, where should I give the command?</strong> </p>
  
  <p>I tried specifying <strong>linesize, wrap</strong> and other commands in the query, but was not working since I have written the query in Oracle SQL. Any help would be greatly appreciated.</p>
  
  <p>Thanks. </p>