Reputation: 145
Can someone explain how to create a text file and save to my C drive from a select query? Anytime I run the query I would like the query to replace the old text file with the new query data.
Upvotes: 0
Views: 4128
Reputation: 647
You will need to follow the steps :
save this in file named get_data.sql
SET HEADING OFF
SET FEEDBACK OFF
SET TERM OFF
SET LONG 100000
SPOOL Dept_100.txt
select 'EmployeeName : '||Emp_id from Employee where Deptno = 100;
SPOOL OFF
on CMD, Go to the folder where the script is.
connect using sqlplus through command prompt.
Run the script
SQL>@spool.sql
spool.sql
contains select statement which will select employeename of all employees who work for Dept :100(Just for example).
Upvotes: 0