Thursday, June 20, 2013

How to copy output of SQL commnads to a text file?

Steps to copy output of SQL commands to text file:

1. Go to SQL prompt:
  


2. Check Present working Directory:
     SQL> !pwd
               

3. create text file which will be saved at above location.
     SQL> spool priya.txt
       

4. After that execute your SQL command,  command & output will be saved in the text file you created.
   
    Note: you can execute as many command as you want  in that text file one after other.

5. Once your finished with your commands, close that text file.
    SQL> spool off;
 

6. Now check text file at the specified location.
  

7. Open that text file & check output.
    > cat priya.txt | more   
   

In this way we can save lengthy output of SQL command in text file.

    

No comments:

Post a Comment