I need a broken 10 second SQL Script

  • Hi,

    I am doing some Q/A work where I am executing a ob that I need to fail - after 10 seconds.

    I am running this and it does fail - but it fails in one second:

    WAITFOR DELAY '00:00:10'

    select top (100) * from sysjobs
    WAITFOR DELAY '00:00:10'

    select blah

    Any ideas

  • krypto69 - Wednesday, January 24, 2018 6:49 AM

    Hi,

    I am doing some Q/A work where I am executing a ob that I need to fail - after 10 seconds.

    I am running this and it does fail - but it fails in one second:

    WAITFOR DELAY '00:00:10'

    select top (100) * from sysjobs
    WAITFOR DELAY '00:00:10'

    select blah

    Any ideas

    Try putting a 'GO' after your WAITFOR DELAY.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • WAITFOR DELAY '00:00:10';
    SELECT 1/0;

    Yours fails instantly because the last query throws a parsing error, and the batch is parsed before any part of it starts executing.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster - Wednesday, January 24, 2018 7:12 AM

    WAITFOR DELAY '00:00:10';
    SELECT 1/0;

    Yours fails instantly because the last query throws a parsing error, and the batch is parsed before any part of it starts executing.

    Ahh..thanks Gail

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

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