outputing select statement result into file

懵懂的女人 提交于 2019-12-11 04:19:54

问题


I have an sql file that contains below script that is ran via isql. May I ask whats wrong with my output syntax? I am getting "Incorrect syntax near the keyword 'output'"

Sybase ASE version is 15.7

select * from tempdb..M3_STI_extracts_checking
output to employee.txt format ASCII
GO

回答1:


isql offers the possibility to write the output into a file, if you set the option -o (Utility Commands Reference).


input.sql

select * from tempdb..M3_STI_extracts_checking
go

isql -i input.sql -o employee.txt

-J sets the charset (ASE 15.7 charsets)

isql -i input.sql -o employee.txt -J ascii_7



回答2:


Was able to workaround by passing the variable from a shell script.

test.sh

output_file=test_file_'date +%m%d%Y' 

${PARAM} isql << EOF 
select * from tempdb..M3_STI_extracts_checking 
GO > ${output_file} 
EOF


来源:https://stackoverflow.com/questions/54882905/outputing-select-statement-result-into-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!