如何使用批处理将数据写入文本文件

时间:2018-11-12 05:23:54

标签: batch-file echo

我已经使用以下代码创建了批处理文件

echo. > Statgather.txt
echo set headING oN; > statgather.txt
echo spool br.txt >> statgather.txt
echo set headING off; >> statgather.txt
echo select * from branchseats where branchcode = '&BRANCHCODE'; >> statgather.txt
echo. >> Statgather.txt
echo spool off; >> statgather.txt
echo quit Statgather.txt

但结果如下

set headING oN; 

spool br.txt 
set headING off;  
spool off; 

请帮助我创建一个批处理文件。谢谢。

1 个答案:

答案 0 :(得分:0)

这是一种方法,在以后询问之前,请先搜索站点

(Echo Line 1
 Echo Line 2
 Echo Line 3
 Echo Line 4)>"Statgather.txt"

某些字符,尤其是与号,重定向字符和右括号,可能需要转义