Error logic in batch file

Last Post 29 Apr 2010 10:54 AM by phsatech. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
New Member
New Member

29 Apr 2010 10:54 AM
I have a simple batch file that runs a few windows commands and then a few osql commands.  We are running SQL 2000, and I'd like to capture the error (s) if present and report back via email.  Here the current script:

@echo on
:Step 1 : Call Backup_Database.bat to backup Production Database
 CD c:\scripts\HR83RPT
ECHO Backing Database
CALL Backup_Database.bat

:Step 2 :use osql to kill any active user sessions
CD c:\scripts\HR83RPT osql -S ZVMPSESQL01 -U sa -P password -i c:\scripts\HR83RPT\uspkill.txt >> c:\scripts\HR83RPT\HR83RPT_refresh.txt echo User sessions have been terminated

:Step 3 :use isql command to kick off refresh executing refresh script CD c:\scripts\HR83RPT echo Refreshing Database isql -S ZVMPSESQL01 -U sa -P password -i c:\scripts\HR83RPT\HR83RPT.sql >> c:\scripts\HR83RPT\HR83RPT_refresh.txt

echo Database Refreshed echo %Date% %Time% >> c:\scripts\HR83RPT\HR83RPT_refresh.txt

:Step 5 :Send Refresh log CD c:\scripts\hr83rpt echo Sending Refresh log file CALL Refresh_Log.cmd

I know various errors can occur and wondering how to capture this and send output to email.  More interested in OSQL commands above that could fail for one reason or another

Appreciate replies.
You are not authorized to post a reply.

Acceptable Use Policy