home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,477 of 19,505   
   Anton Shepelev to All   
   Re: `sqlcmd' defective by design?   
   13 May 24 17:32:01   
   
   From: anton.txt@g{oogle}mail.com   
      
   I wrote:   
      
   > I have a nasty problem in my automation batch scripts that   
   > invoke `sqlcmd`: whatever I try, I cannot cause it to   
   > terminate with an error level in case of a timeout.   
      
   The only solution I have found is to detect the words   
   "Timeout expired" in the standard output.  Here is a sample   
   batch script:   
      
     @ECHO OFF   
     SET OUT=out.txt   
     SET ERR=err.txt   
      
     sqlcmd -S  -V 11 -r -b -t 1 -i test.sql  >%OUT% 2>%ERR%   
      
     :: Handle a normally reported error:   
     IF ERRORLEVEL 1 GOTO Error   
      
     :: Handle a timeout, by examining the first line of stdout:   
     SET /P OUT_FST=<%OUT%   
     IF "%OUT_FST%"=="Timeout expired" (   
         ECHO equ!   
         COPY %OUT% %ERR%   
         GOTO :Error   
     )   
      
     :: No errors detected, exiting:   
     ECHO All went well.   
     EXIT /B   
      
     :Error   
     echo Error encountered:   
     type %ERR%   
      
   I have published this on StackOverflow:   
      
      
   --   
   ()  ascii ribbon campaign -- against html e-mail   
   /\  www.asciiribbon.org   -- against proprietary attachments   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca