How many Records Will Get Selected

  • I would vote for a comment on the ADD CONSTRAINT that it had an intentional syntax error. Sort of like editors adding "[sic]" in a quote to let people know something is misspelled or misused. I would not say anything more about the outcome, because this does have several elements that affect the impact of the errors.

    A good QoD brings home a lesson, and thinking about "what if things don't go as planned" is one of the most valuable lessons you can learn. Working as if the plan will have some potholes is one of the differences between the professional and the amateur.

    For example, I've recently learned to add the following in DDL scripts; saves me from cleaning up the master database when the script runs on the wrong server and/or database:

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

    ---

    USE [MyDB]

    GO

    IF DB_NAME() <> 'MyDB'

    BEGIN

    PRINT 'MyDB database does not exist on this server!!!'

    PRINT ' ===== SET NOEXEC ON !!! ====='

    PRINT ''

    SET NOEXEC ON

    END

    GO

    -- SET NOEXEC OFF

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

    “The measure of an education is that you acquire some idea of the extent of your ignorance” --Christopher Hitchens

    David Lathrop
    DBA
    WA Dept of Health

  • I also figured the syntax error was a typo and went ahead and worked out one row would get inserted. I did not think to see if the answer for the constraint command erroring off was also there.

    -- Mark D Powell --

  • not a good question at all!

    'nuf said.

  • lmu92 (6/11/2010)


    I second Ninja's_RGR'us recommendation regarding the script screenshot.

    For two reasons:

    #1) it requires at least a little more effort to run it before answering (for those who otherwise would just do a copy and paste) and

    #2) There would be no room for guessing if a typo is a typo or intended.

    Really? You think if it is a screen shot instead of selectable text that there you would consider it didn't have a typo? Either way someone had to type it, so there is a chance that a typo got in and you would have no way to know if the typo was initial or not.

    In this case it was missing both the opening and closing parenthesis, which makes it seem more on purpose.

    Unless there are rules I am unaware of I assume that you have to take the question as it is displayed. I've seen in the past where there was an unintentional typo that Steve corrected it and awarded points where they should have been earned.

  • WTF? A question where you're supposed to spot a syntax error and figure out the correct answer, rather then working through the logic that seems right? This question sucks.

    Paul Randal
    CEO, SQLskills.com: Check out SQLskills online training!
    Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal
    SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine
    Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005

  • Question is not to good. But you should mention that "do change the script"...

    and i think this is first time is history in SSC and we should get back are points...

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • There are some practices, unwritten as far as I know, that generally seem to be followed in the QotD.

    For instance, the default settings are always assumed, unless otherwise stated.

    Likewise, if the T-SQL generates a syntax error, the correct answer generally at least mentions the syntax error. Because if any code generates a syntax error, its output is pretty moot - the code needs to be corrected regardless.

    That seems to be the problem with this otherwise good question - it did not mention the syntax error in its correct answer, leaving everyone to guess whether or not that was intentional.

  • UMG Developer (6/11/2010)


    lmu92 (6/11/2010)


    I second Ninja's_RGR'us recommendation regarding the script screenshot.

    For two reasons:

    #1) it requires at least a little more effort to run it before answering (for those who otherwise would just do a copy and paste) and

    #2) There would be no room for guessing if a typo is a typo or intended.

    Really? You think if it is a screen shot instead of selectable text that there you would consider it didn't have a typo? Either way someone had to type it, so there is a chance that a typo got in and you would have no way to know if the typo was initial or not.

    In this case it was missing both the opening and closing parenthesis, which makes it seem more on purpose.

    Unless there are rules I am unaware of I assume that you have to take the question as it is displayed. I've seen in the past where there was an unintentional typo that Steve corrected it and awarded points where they should have been earned.

    There's one important point missing in that quote, I also said to categorize it in a syntax category, not only using a screenshot.

    Thanks for your comments.

  • I am not sure to consider this question as good or bad?

    But the fact is I have fixed the syntax and opt for answer 1 and lost 3 points.

    Here is the Simple Truth:

    1. If you do not need Check constraint answer is 3.

    2. If you need Check constraint answer is 1.

    Now hope everybody got the 3 POINTS(virtually) :hehe:

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • luckily didn't correct the syntax error, hence got it right.

    Ideally such kind of questions should be put in a different category so that people don't assume that syntax error has been done by mistake.

  • i new the answer but still last my points because i ignored the systax error. at least could have provided the sysntax error option which will enable us to think about syntax of the Query.

  • This was really a trick question! I assumed the constraint was correct and it was a bad assumption.

    /Håkan Winther

    SQL Service AB

    /Håkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform

  • Lots of people seem to be saying that because lots of other QotDs have contained accidental syntax errors, then this one is a BAD QUESTION because it contains an intentional syntax error but the errors in the rest made people assume that this one was a mistake too.

    Surely those other questions are the bad ones, rather than this one?

  • There have been other QoD's that contained "mistyped" code that would cause unintended results. This one is just different because the SQL syntax analyzer catches an error and writes an error message as part of the execution. What surprises is the way the entire script is processed.

    In other cases, its a matter of code that at first appears correct, but may not be complete, demonstrates a special case, or implicitly depends on specific processing orders and side effects. The right answer often requires looking at the code in a certain way to see the problem before it runs. For example, "SELECT a FROM t WHERE a = a" will not return all rows in "t" if "a" is NULL when ANSI_NULLS is ON, but setting ANSI_NULLS to OFF can introduce all kinds of problems and errors (do you remember all of these?). [Sorry for the weak example, but I don't usually come up with QoD's.]

    In this case, not having parentheses is a syntax error, but in an expression it may affect the structure and result and not the validity.

    So this is a valid QoD for me.

    David Lathrop
    DBA
    WA Dept of Health

  • Even though I received 3 points in this question, it leaves a bad taste in my mount. I still had to guess (correctly) that the intent of the author was to ask a trick question.

    All in all, not the greatest QOD.

    Converting oxygen into carbon dioxide, since 1955.

Viewing 15 posts - 46 through 60 (of 75 total)

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