In this article You will learn how to use SPOOL
Command in SQL Server.
SPOOL Command:-
A command called
SPOOL that can send the
output from any SQL statement to a file. Indeed, anything that is displayed in
SQL*Plus can be echoed to this spool file. The
SPOOL command is invoked
with the name of a file that will contain the output. Once this has been
executed, the output from all subsequent SQL statements will be copied to the
file. To end capturing the output, issue the
SPOOL OFF command.
Spooling can be used in two type one through
the write some command in PL/SQL prompt and other option can be used command
prompt menu option. it will be create when:
First option to use SPOOL command through
the command prompt menu:
oracle SQL*plus->File->spool->spool file
-- write the statement in oracle SQL*Plus
after the statement end of the spool through the spool off.
Such as:
![spool1.gif]()
now Click the spool file than spooling will be start and select the path.
after
selecting the path execute some statement on the command prompt it will
be save in a file to the proper place where you have selected the path.
at the end close the spool command with the option spool off. such as
oracle SQL*plus->File->spool->spool off
now open the file file will be created with statement output.
Second option to use the spool command
through the write command in command prompt:
![spl2.gif]()
file File1 is created in the proper define path with the output.The SPOOL OFF command turns the output off. Everything between
SPOOL c:\file1.out and SPOOL OFF will be in the file file.out
Read more articles related Oracle Click Here