Timestamps

  • hany.helmy (5/5/2013)


    I think the answer is wrong as statement #7 runs succesfully and returns 0 rows & also statements #8 run succesfully and didn`t fail for any reason!!

    Any explanation dear author?!! :cool:;-)

    Run the following as a SINGLE BATCH and tell us what you see in the messages tab:

    -- statement #1

    print 'Statement 1';

    create table #QotD1 (Id int, timestamp timestamp)

    -- statement #2

    print 'Statement 2';

    insert into #QotD1 (Id)

    select top 10 id from sys.sysobjects

    -- statement #3

    print 'Statement 3';

    select id, timestamp into #QotD2 from #QotD1

    -- statement #4

    print 'Statement 4';

    select *

    from #QotD1 q1

    join #QotD2 q2 on q1.timestamp = q2.timestamp

    -- statement #5

    print 'Statement 5';

    delete #QotD2

    -- statement #6

    print 'Statement 6';

    insert into #QotD2 (Id, timestamp)

    select id, timestamp from #QotD1

    -- statement #7

    print 'Statement 7';

    select *

    from #QotD1 q1

    join #QotD2 q2 on q1.timestamp = q2.timestamp

    -- statements #8

    print 'Statement 8';

    drop table #QotD1

    drop table #QotD2

  • statement #7 runs succesfully and returns 0 rows

  • binod.soft (5/8/2013)


    statement #7 runs succesfully and returns 0 rows

    Not if you execute the entire code block as a single batch (as instructed in the question). The error in statement #6 aborts the batch; statements 7 and 8 are not executed.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Nice question. Thanks for author for submitting. Please keep posting this type of good questions.

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • Interesting question, thanks for the effort!

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Hugo Kornelis (5/6/2013)


    To the many people complaining they "lost" points - you didn't. You still have as many points as you had before, and by wasting yours and other people's time with your whining, you even earned an extra point. (Can someone please give Steve an entry-level book about raising kids? You know, one that explain you should not reward unwanted behaviour?)

    Heh... I see that you've gotten several extra points pointing that out. 😉

    --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.


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

  • I was too fast. Lost my points. Good question though.

  • Nice question. Had to give lots of time to go through each statement. 🙂

  • Hugo Kornelis (5/6/2013)


    And finally, to Steve - I know we've discussed this before, and I know it won't happen, but I just have to ask again. Can you please, please, please get rid of that stupid point system. The only effect I see it having is to encourage behaviour that benefits nobody.

    What he said.

  • Just to be clear, it's not so much "points" that people value. It's the reported percentage of correct answers that people value because it's one of those things that can look pretty good on a resume.

    --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.


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

  • Jeff Moden (5/25/2013)


    Just to be clear, it's not so much "points" that people value. It's the reported percentage of correct answers that people value because it's one of those things that can look pretty good on a resume.

    Are you sure about the resume? I don't know as I joined SSC during my recent job and I'm not responsible of employees.

    I suppose that minority of HR in our country even heard about SSC.



    See, understand, learn, try, use efficient
    © Dr.Plch

  • Hugo Kornelis (5/6/2013)


    What bothers me most about the point system is that it causes some people who feel a question was unfair to respond downright angry, demanding "points back" and stuff. I have no idea how value-less points cause people to expose their dark side in such ways. But I don't like it, and if taking away the points system would rid us of those post, I am all for it.

    I do maintain that some of the "thank you" posters are, as far as I can see, not sincere. I especially get this feeling when I see a single person post equal-worded "thank you" posts in all topics of the last two weeks, and then does it again in another two weeks. I may be wrong, but it simply does not give me a sincere feeling.

    For people who occasionally post a "thank you" after reading a question they like, or if they feel an author deserves to be compensated for an unfair bashing, I have no problem at all. It is not something I myself do very often, but I have no issue with those who do so,

    However, just to ensure I am not misunderstood - the main reason why I would like Steve to get rid of the points system is to get rod of the nasty and hostile messages of people who are angry when they miss points.

    Well, Hugo, I possibly do understand quite well your motivation to flame a little bit against the point system.

    On the other hand, I myself appreciated this point system because I wanted to have proof of my development in the SQL area. And the point system gave me motivation at starters.

    Now some days are gone, and I got too impatient watching me still being a "Valued member". I got more interested in the technical aspects of the QotD. And for _me_ it is very valuable to see which people are complaining, which are just writing a "thanx" and which people's articles are worth reading.

    Yours definitely are of the latter. So thanx to you, too 😉

    ________________________________________________________
    If you set out to do something, something else must be done first.

Viewing 12 posts - 46 through 56 (of 56 total)

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