BTEQ: Save Teradata error in logfile

一曲冷凌霜 提交于 2019-12-11 13:07:05

问题


My goal is to automate a deployment of SQL scripts to Teradata via BTEQ. So far my script is working. However, I would like to generate a log file where possible failures are captured.

.LOGON tdserver/username,pw
.EXPORT file=\logfile.txt;

.run file = \Desktop\test\test.sql;

.LOGOFF
.EXIT

My SQL script will create a VIEW. When this view for example already exists I see an error in the BTEQ command window:

*** Failure 3804 View 'ViewName' already exists.

I would like to have this TD Message in my log file. I tried several tings, have been looking for 3 hours but unfortunately without success.


回答1:


You may want to experiment using .SET ERROROUT STDERR which re-routes the error stream to the STDERR output file instead of the default action of routing the error stream to STDOUT.

There is more information in the BTEQ manual under Chapter 5 - BTEQ Commands.




回答2:


Save all your script written above as a text file and create a batch file that generates a log after running the script:

echo off
bteq < script.txt > script.log 2>&1
@echo off goto end
:end
@echo exit

Errors will be recorded in this way.



来源:https://stackoverflow.com/questions/36792868/bteq-save-teradata-error-in-logfile

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