Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #2243

Re: `sqlcmd' defective by design?

Path csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Anton Shepelev <anton.txt@g{oogle}mail.com>
Newsgroups comp.databases.ms-sqlserver
Subject Re: `sqlcmd' defective by design?
Date Mon, 13 May 2024 17:32:01 +0300
Organization A noiseless patient Spider
Lines 41
Message-ID <20240513173201.9c1a6357b3e12cfd140c12d2@g{oogle}mail.com> (permalink)
References <20240513142445.206132420c1c47759b78c197@g{oogle}mail.com>
MIME-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
Injection-Date Mon, 13 May 2024 16:32:02 +0200 (CEST)
Injection-Info dont-email.me; posting-host="918042726379315a16e3ca198a19385c"; logging-data="3696848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Azenay+H7tldx8XRIa/8Ik9/DYKkqCJw="
Cancel-Lock sha1:OZEHaUgyC10YlIvMWmC9gW9WE9Q=
X-Newsreader Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Xref csiph.com comp.databases.ms-sqlserver:2243

Show key headers only | View raw


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 <your_server> -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:
<https://stackoverflow.com/a/78472213/2862241>

-- 
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

`sqlcmd' defective by design? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-05-13 14:24 +0300
  Re: `sqlcmd' defective by design? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2024-05-13 17:32 +0300
  Re: `sqlcmd' defective by design? Erland Sommarskog <esquel@sommarskog.se> - 2024-05-13 22:44 +0200
    Re: `sqlcmd' defective by design? Anton Shepelev <anton.txt@gmail.moc> - 2024-05-14 01:05 +0300
      Re: `sqlcmd' defective by design? Erland Sommarskog <esquel@sommarskog.se> - 2024-05-14 21:23 +0200

csiph-web