GO

  • cfradenburg (6/7/2011)


    dmoldovan (6/7/2011)


    And I have one more question - why do you ask about "the output of this batch"? As far as I can see there are 3 batches, separated by "GO". Am I missing something?

    Technically it is three different batches but based on context it's really easy to get that the author was referring to the set of three batches as one large batch. Now, I'm sure someone is going to say that using "batch" in this way is complete unacceptable but I don't see anything really wrong with it.

    I've got it. But "script" would have been more appropriate.

  • wware (6/7/2011)


    cfradenburg (6/7/2011)


    I see your post regarding 1 batch vs. 3 batches, but I don't see an answer about why SSMS suggests a syntax problem with the "50" by giving it a red squiggly underline. Am I missing something?

    Sorry, I was reading fast and made an assumption about what you were quoting. I can say on my SQL 2008R2 SP2 CTP box it didn't do that. It could be a bug that got fixed.

  • WayneS (6/6/2011)


    Actually, none of those choices are correct. You get back 50 random GUID values.

    1. NEWID() returns a random GUID (aka uniqueidentifier)

    2. Select statement has no order by clause, so the results are random.

    3. The GO 50 repeats that batch 50 times (if in SSMS and the batch separator is set to "GO")

    The answer annotated as correct ("50") is not correct... the results are 50 random GUID values. You do NOT receive "50" as the result set to this query.

    I ended up reading the question, reading the answers, deciding that I must be losing my mind, running the query to see what I was missing, re-reading the answers, and deciding that I had no idea how to translate the actual results into the list of possible answers.

    So I'm not answering today's question unless we end up with a set of answers that actually matches the question.

    -Ki

  • cfradenburg (6/7/2011)


    wware (6/7/2011)


    cfradenburg (6/7/2011)


    I see your post regarding 1 batch vs. 3 batches, but I don't see an answer about why SSMS suggests a syntax problem with the "50" by giving it a red squiggly underline. Am I missing something?

    Sorry, I was reading fast and made an assumption about what you were quoting. I can say on my SQL 2008R2 SP2 CTP box it didn't do that. It could be a bug that got fixed.

    I get an "incorrect syntax near 50" message when hovering on the text in SSMS. However the script works as expected. I work on SQL 2008 dev edition SP2

  • dmoldovan (6/7/2011)


    cfradenburg (6/7/2011)


    wware (6/7/2011)


    cfradenburg (6/7/2011)


    I see your post regarding 1 batch vs. 3 batches, but I don't see an answer about why SSMS suggests a syntax problem with the "50" by giving it a red squiggly underline. Am I missing something?

    Sorry, I was reading fast and made an assumption about what you were quoting. I can say on my SQL 2008R2 SP2 CTP box it didn't do that. It could be a bug that got fixed.

    I get an "incorrect syntax near 50" message when hovering on the text in SSMS. However the script works as expected. I work on SQL 2008 dev edition SP2

    Do you have red-gate's sql prompt? I have it throw errors like that in the past. It's not 100% accurate afaik (but I have an older version).

  • Correction:

    Select count(*) from Test

    will result into 50,

  • Can anyone who's said it's confusing, explain how any answer other than '50' could possibly be right? To answer '50' needs an assumption that they meant 'count(*)' rather than '*'. What similarly simple assumption couild make any of the other options correct?

  • Sadly, people would rather have a moan than cut the question setter a little slack. We all know what he meant to write so why not use that knowledge to tick the correct answer and move on with a bit of grace and humanity?

  • Did you guys actually read the question recently??? It says count(*).

  • Ninja's_RGR'us (6/7/2011)


    Did you guys actually read the question recently??? It says count(*).

    A few hours ago it was "SELECT * FROM Test"

  • dmoldovan (6/7/2011)


    Ninja's_RGR'us (6/7/2011)


    Did you guys actually read the question recently??? It says count(*).

    A few hours ago it was "SELECT * FROM Test"

    I know.

    Question corrected.

    Thanks for feedback.

    Time for a work break! :hehe:

  • Toreador (6/7/2011)


    Can anyone who's said it's confusing, explain how any answer other than '50' could possibly be right? To answer '50' needs an assumption that they meant 'count(*)' rather than '*'. What similarly simple assumption couild make any of the other options correct?

    I said the original set of answers was confusing - because there was no correct answer to the question. I generally don't object to using common sense in the QOTD, because I know how hard it is to word questions in a way that everyone interprets the same way.

    But there's a significant difference between select * from test and select count(*) from test and the results that one receives from those two statements. I personally see no reason to guess at what the author intended to write, and don't have any problem with people who read the original question with the original answers scratching their heads in confusion.

    -Ki

  • Richard Warr (6/7/2011)


    Sadly, people would rather have a moan than cut the question setter a little slack. We all know what he meant to write so why not use that knowledge to tick the correct answer and move on with a bit of grace and humanity?

    Obviously, we all did *not* know what the author meant to write. I haven't seen anyone being nasty in this thread - I've just seen confusion. Since when is expressing confusion showing a lack of grace and humanity?

    -Ki

  • Like

  • My apologies. The question has been corrected with a count(*) instead of a SELECT *. I am sure that I saw 50 results in testing and let it go as "there were 50 rows", thinking the question was testing the "go 50" and you'd all be able to read the author's mind.

    I will award back points as soon as my VPN is repaired.

Viewing 15 posts - 31 through 45 (of 54 total)

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