Delaying the code

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 721381

    Comments posted to this topic are about the item Delaying the code

  • HappyGeek

    SSCoach

    Points: 18684

    Nice question, thanks Steve.

    ...

  • ako58

    Hall of Fame

    Points: 3443

    between "WAITFOR DELAY '00:02.5':ย  and "WAITFOR DELAY '00:02:00.5'" is the big difference

  • Thom A

    SSC Guru

    Points: 98776

    Had to double check that one before I confirmed my answer; trying to be tricky with the first questions of the year, are we Steve? ๐Ÿ˜‰

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Jeff Moden

    SSC Guru

    Points: 997311

    BWAAAA-HAAAA-HAAAA!!!!ย  I'm thinking that this question is the result of someone learning something the hard way! ๐Ÿ˜€ ๐Ÿ˜€ ๐Ÿ˜€

    Great "gotcha" question, Steve!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 721381

    Not trying to be too tricky, but just struggling to come up with answers that might be plausible, or be easy mistakes to make. I haven't actually done this, mostly because I test the heck out of anything where I use this because I worry I'll format time wrong.

    This code would never get edited in production without being tested somewhere.

  • Jeff Moden

    SSC Guru

    Points: 997311

    Right there with you on the "test the heck out of anything".

    To be absolutely honest, I have no idea how you even came across this especially since it's not a documented time format (at least not one I've come across before).ย  That makes it an even greater question.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Stewart "Arturius" Campbell

    SSC Guru

    Points: 71932

    Back in the land of the connected (spent the last 2 weeks in the bush, in the middle of nowhere (no mobile connectivity)).

    Nice reminder of the intricacies of the TIME datatype (especially the undocumented ones), thanks Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    โ€œlibera tute vulgaris exโ€

  • Thom A

    SSC Guru

    Points: 98776

    Stewart "Arturius" Campbell wrote:

    Back in the land of the connected (spent the last 2 weeks in the bush, in the middle of nowhere (no mobile connectivity)).

    Nice reminder of the intricacies of the TIME datatype (especially the undocumented ones), thanks Steve

    The varchar passed for WAITFOR isn't parsed as a time (or at least the SQL Server version of it).ย  The value '00:02.5' results in a conversion error if you try to convert it (to a time), due to it missing the seconds before you get to the milliseconds:

    SELECT CONVERT(time(1),'00:02.5') AS Delay;

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

Viewing 9 posts - 1 through 9 (of 9 total)

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