How many Records Will Get Selected

  • bazzkar

    SSC Veteran

    Points: 270

    Comments posted to this topic are about the item How many Records Will Get Selected

  • Kingston Dhasian

    SSCoach

    Points: 19794

    Another Trick Question that is sure to generate quite a bit of debate. You dont learn anything new, and lose 3 points. I am sure many would be knowing the answer but will choose the wrong option because of the construction of the question. I would suggest to put such questions under a different criteria called TRICK QUESTION or something so that people dont feel fooled.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • SQLRNNR

    SSC Guru

    Points: 281210

    I don't see this as a trick question. I see it as a good question. There is something to be learned from this question and thus it is worthwhile.

    Thanks for the QOD.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • malleswarareddy_m

    SSCertifiable

    Points: 5847

    Hi i know this answer it was syntax wrong but i put 1 as wrong anwer.

    because i thought that there may wrong with script.I know that this script will give sytax error.But i thought that there is some print mistake.

    then i correct it to.

    Alter table mytable with check Add constraint[checkmainvalue] check(([mainvalue])> (0))

    then executed.this gives me 1 as result.because the conditon satisfied for 1 only.

    This question is not difficulty.it divorsed me to put wrong anwer.There is nothing new learn from this question.

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

  • Christian Buettner-167247

    SSChampion

    Points: 13729

    Hm, looks like I misinterpreted the intention of the author.

    My assumption was, that the question was about whether an error in one of the INSERT operations aborts the full batch. I did see the missing parentheses, but since there have been so many erroneous questions in the past, I also considered this one to be an error of the author.

    Well, better luck next time...

    Best Regards,

    Chris Büttner

  • Carlo Romagnano

    SSC-Insane

    Points: 21748

    There is nothing new learn from this question.

    The lesson is:

    "GO" may be dangerous if no error checking is done!

  • Kingston Dhasian

    SSCoach

    Points: 19794

    CirquedeSQLeil (6/10/2010)


    I don't see this as a trick question. I see it as a good question. There is something to be learned from this question and thus it is worthwhile.

    Thanks for the QOD.

    I agree there may be some who might learn something from the question. A definite good question for them no doubt. But i thought the question had a typo and selected the wrong answer. How do i know if the syntax error was deliberate or just a mistake? We have had instances in the past where it was just a typo.

    The first thing i do when i come to office is open my SSMS and then SSC QOTD. And when something like this happens it definitely irritates you a bit. Same happened with me.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Hugo Kornelis

    SSC Guru

    Points: 64645

    I do not like this kind of question at all. The QotD should be a learning opportunity, with clear questions and no tricks.

    There is nothing to be learned from this question. In a real situation, the error in the syntax would be obvious as soon as the code is executed, and it would be corrected before users get to add data.

    The lesson is:

    "GO" may be dangerous if no error checking is done!

    If that was the intended lesson, then the example is very badly chosen. Come on! How realistic is a script that adds a constraint and then immediately adds some data that obviously violates that constraint. I can only envisage that in a test database, where someone wants to test if constraints work as expected (not a bad idea, especially if NULL values are involved) - but in that case, checking the test output would immediately expose the problem and allow the developer to correct it. Which is the very purpose of running a test script.

    Another problem I have is that this kind of questions call for psychic powers on our part. Others have already commented that it might have been a honest mistake by the author, and we are suppose to answer based on a succesfull constraint creation (such errors and expectation have occured in the past).

    A problem not yet pointed out, but relevant in this and many other questions, is case sensitivity. Even if the missing parentheses are added, the constraint would still not be created in my test database, since I run a case sensitive collation (so "mytable" is not the same as "MyTable"). Other people will use different collations, and hence get a different result. How am I suppose to know what the author had in mind?

    This all being said, I'd still like to say "thank you" to bazzkar for contributing this question. Please take my reaction as it's intended, as constructive feedback. Don't let it discourage you from contributing more questions in the future, but do keep the feedback in mind to make your future questions better.


    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/

  • Toreador

    SSChampion

    Points: 11227

    Well I learnt something, though probably not what was intended.

    Believe it or not, I never realised that identity columns are ignored if you could insert into a table using that syntax, ie not giving a column list. I've always coded such things as

    insert into MyTable (mainvalue) values (-1)

    on the assumption that otherwise it would give an error about fewer values than columns!

  • george sibbald

    SSC Guru

    Points: 104200

    Its a trick question that encourages people to just cut and paste and see what happens.

    the question appears to be on how constraints work but is in effect testing your knowledge of syntax (or ability to cut and paste). Who remembers all details of syntax?

    ---------------------------------------------------------------------

  • malleswarareddy_m

    SSCertifiable

    Points: 5847

    Carlo Romagnano (6/11/2010)


    There is nothing new learn from this question.

    The lesson is:

    "GO" may be dangerous if no error checking is done!

    This type Go questions and answers and disscussions are there.

    Please check previous questions long back you know this type questions as much as there.

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

  • Mighty

    SSCrazy Eights

    Points: 8435

    Quite a waste of time trying to answer this question.

    Lesson learned here should be: How NOT to write a QotD!

  • ronmoses@gmail.com

    SSCarpal Tunnel

    Points: 4480

    Well I learned two things. One, be careful with those GO statements, they can bite you in the butt. Two, write a QotD that trips up a bunch of people and they'll come crawling out of the woodwork to cry about what a bad question it is.

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • Open Minded

    SSCommitted

    Points: 1842

    i don't copy and paste before answering the qotd. because if i answer it right, i wouldn't join the debate. only twice or so did I ever join a debate when i got it right. so then, i could stand upon my meager pile of points and crow to the high heavens that i earned them the hard way: "real men drink from bottle" :w00t:

    ok, i climb down from the soap crate.

    there's a certain canadian company which sells puzzles. i once ordered from them and the puzzles came through to the island where i am. i am deciding on their sale of one of the metal ones. it is level 9, very difficult. they also have hanayama puzzles with varying levels. imagine puzzles, having different levelling.

  • Ninja's_RGR'us

    SSC Guru

    Points: 294069

    Just my 0.02$, I don't care about the points but I fail to see the learning opportunity (for me) here. Like hugo said, you'll get an error as soon as you test the script. So it comes back to assuming the intent of the question, coin flip at best.

Viewing 15 posts - 1 through 15 (of 76 total)

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