Sqlcmd with Timeout Error

  • I have a script that is executed with sqlcmd and have set the timeout to 30 seconds (-t 30). When I run it in a DOS window, I get an "timeout expired" error, but the ERRORLEVEL returned is still 0. I have also set the SeverityLevel to 1 (-V 1).

    How can I catch this timeout and log the error ?

     

  • this surprises me.  Are you sure you are checking ERRORLEVEL correctly?

    can you post the relevant part of your batch script? 

    ---------------------------------------
    elsasoft.org

  • Put this in a .sql file

    SET NOCOUNT ON

    DECLARE @DelayLength char(8)

    SET @DelayLength = '00:00:50' -- delay for 50 seconds

    WAITFOR DELAY @DelayLength

    Put this in a batch file and run is a dos window

    @ECHO OFF

    sqlcmd -E -S {ServerName} -d {DatabaseName} -t 5 -b -V 1 -i {ScriptFileName With path created above}

    ECHO %ERRORLEVEL%

     

  • sure enough.  this pretty much sucks for automating your scripts I have to say.

    this issue has been raised before here on ssc and not answered:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=145&messageid=343395

    if I were you I would post it on one of the ms newsgroups and someone from the sql server tools team may answer.  here for example:

    http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=84&SiteID=1

    ---------------------------------------
    elsasoft.org

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply