我有一个需求,我需要从.bat文件运行.sql文件。 .sql文件的输出应该重定向到.txt文件。我能够做到这一点,但是sql文件正在打印以'_'加下划线的列名,并且在文件末尾打印'3 rows selected'。我不希望列名和'3 rows selected'出现在输出文件中。你能指出我在这里做错了什么吗? 以下是我的代码的详细信息。请注意,我的sql必须使用sqlplus在oracle数据库中运行。从批处理文件运行SQL脚本 - 输出不如预期
sql_file.sql
SET HEADING OFF FEEDBACK OFF ECHO OFF PAGESIZE 0
SET UNDERLINE off
select 'This '|| emp_name || ' belongs to ' || dept_name || ' department' as emp_data from emplyoee;
exit
batch_file.bat
@echo off
sqlplus -s -l scott/[email protected] @"C:\Data Files\sql_file.sql" >> "C:\Data Files\output_file.txt"
我想output_file.txt看起来像
This Charles employee belongs to Finance department
This Chris employee belongs to Sales department
This John employee belongs to Engineering department
但是我的代码正在生产输出
emp_data
--------------------------------------------------
This Charles employee belongs to Finance department
This Chris employee belongs to Sales department
This John employee belongs to Engineering department
3 rows selected
为什么你也许可以使用批处理文件代码去除标题和预告片记录,我相信你只是改变你的查询,以便它不输出该信息。你应该改变你的问题标签,以包括类似sql查询。我的DB人员始终输出查询,并且永远不会输出标题和预告片信息。 – Squashman
这很奇怪 - 我测试了你的sql脚本(包括套件的一行),它对我有用。你使用什么版本? (我测试它在11.2.0.1) –
这种看起来像你的问题:http://stackoverflow.com/questions/28689851/remove-column-header-into-the-ouput-text-file – Squashman