|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 8:26 AM
Points: 3,164,
Visits: 4,344
|
|
Nice, simple, back-to-basics question, thanks, Dave
____________________________________________ Space, the final frontier? not any more... All limits henceforth are self-imposed. “libera tute vulgaris ex”
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 12:56 AM
Points: 2,501,
Visits: 2,201
|
|
Nice question - thanks
------------------------------- Posting Data Etiquette - Jeff Moden Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan I would never join a club that would allow me as a member - Groucho Marx
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:42 AM
Points: 5,298,
Visits: 7,241
|
|
When picking my answer, I knew I had a 50/50 chance, because my mindreading skills are still not on par with my SQL skills.
There were two options.
1. The author knows very well what a batch is, and also knows very well that GO ends a batch. The phrasing of the question: "as 1 batch" was deliberate, as a sign that you should answer the question as if the GO lines are not there. He deliberately put them in to trap the people who just copy/paste the code.
2. The author either doesn't know what a batch is, isn't aware what GO does, or wass not paying sufficient attention when adding that "as 1 batch" to the question. He meant that the entire code should be executed at once (allthough that is actually irrelevant, the results are the same if the batches, or evne the individual statements, are sent and executed one by one).
In the first case, the entire batch will fail at parse and compile time, so none of the statements will actaully execute. You get an error message and nothing happens. The option "All statements will fail", though technically not 100% accurate (as there is a single failure of a whole batch, not multiple failures of incividual statements), comes close enough to be considered the correct answer. In the second case, the first batch will compile and execute successfully, the second batch will fail compilation and not execute, and the third batch will compile and execute successfully. The option "Only the 1st and 3rd statement will succeed but no rows will be returned", though technically not 100% accurate (as the 4th statement will also succeed), comes close enough to be considered te correct answer.
I threw my dart to pick one of the two options, and failed. Oh well.
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:42 AM
Points: 5,298,
Visits: 7,241
|
|
Koen Verbeeck (2/10/2013)
For me the question was more about the fact you can use Integer instead of int. Didn't know that  The question cleverly had no color coding on the word Integer, so I assumed SSMS didn't recognize it. But actually it does when you copy paste the code into SSMS. I think that's a shortcoming of SQLServerCentral's color-coding algorithm. Last time I submitted a question, I just had to paste in the query and the color-coding was added automagically.
I'm surprised you didn't know this. Integer is actually the official name; int is an accepted abbreviation. *cough* I have to retract the above. That's what I always thought, but when I went out to find a Books Online reference, I was surprised to see only "int" there. "Integer" is not even mentioned. 
EDIT: Found the source of my confusion. The ANSI documents describing the SQL standard define both INT and INTEGER, and describe INT as "equivalent to INTEGER". I've always interpreted that as "INTEGER" being the official form and "INT" being an accepted alternative.
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 1:37 AM
Points: 275,
Visits: 222
|
|
Hugo Kornelis (2/11/2013) When picking my answer, I knew I had a 50/50 chance, because my mindreading skills are still not on par with my SQL skills.
There were two options.
1. The author knows very well what a batch is, and also knows very well that GO ends a batch. The phrasing of the question: "as 1 batch" was deliberate, as a sign that you should answer the question as if the GO lines are not there. He deliberately put them in to trap the people who just copy/paste the code.
2. The author either doesn't know what a batch is, isn't aware what GO does, or wass not paying sufficient attention when adding that "as 1 batch" to the question. He meant that the entire code should be executed at once (allthough that is actually irrelevant, the results are the same if the batches, or evne the individual statements, are sent and executed one by one).
In the first case, the entire batch will fail at parse and compile time, so none of the statements will actaully execute. You get an error message and nothing happens. The option "All statements will fail", though technically not 100% accurate (as there is a single failure of a whole batch, not multiple failures of incividual statements), comes close enough to be considered the correct answer. In the second case, the first batch will compile and execute successfully, the second batch will fail compilation and not execute, and the third batch will compile and execute successfully. The option "Only the 1st and 3rd statement will succeed but no rows will be returned", though technically not 100% accurate (as the 4th statement will also succeed), comes close enough to be considered te correct answer.
I threw my dart to pick one of the two options, and failed. Oh well.
+1 
Execute as 1 Batch and results are combined toghether hence my result below therefore I answered as "All statements will fail". 
Msg 2714, Level 16, State 6, Line 3 There is already an object named '#TempQoD' in the database.
(0 row(s) affected)
Regards ld
Stoke-on-Trent United Kingdom
If at first you don't succeed, go to the pub and drink away your current thought plan.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, June 12, 2013 9:12 AM
Points: 1,167,
Visits: 646
|
|
| Well, I thought it was a nice question or maybe I was too naive to think it might be a trick
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 12:10 PM
Points: 7,185,
Visits: 7,285
|
|
Hugo Kornelis (2/11/2013) When picking my answer, I knew I had a 50/50 chance, because my mindreading skills are still not on par with my SQL skills.
There were two options.
1. The author knows very well what a batch is, and also knows very well that GO ends a batch. The phrasing of the question: "as 1 batch" was deliberate, as a sign that you should answer the question as if the GO lines are not there. He deliberately put them in to trap the people who just copy/paste the code.
2. The author either doesn't know what a batch is, isn't aware what GO does, or wass not paying sufficient attention when adding that "as 1 batch" to the question. He meant that the entire code should be executed at once (allthough that is actually irrelevant, the results are the same if the batches, or evne the individual statements, are sent and executed one by one).
In the first case, the entire batch will fail at parse and compile time, so none of the statements will actaully execute. You get an error message and nothing happens. The option "All statements will fail", though technically not 100% accurate (as there is a single failure of a whole batch, not multiple failures of incividual statements), comes close enough to be considered the correct answer. In the second case, the first batch will compile and execute successfully, the second batch will fail compilation and not execute, and the third batch will compile and execute successfully. The option "Only the 1st and 3rd statement will succeed but no rows will be returned", though technically not 100% accurate (as the 4th statement will also succeed), comes close enough to be considered te correct answer.
I threw my dart to pick one of the two options, and failed. Oh well. I went through exactly the thought process Hugo describes, and answered that all three will fail (the only option that gives the same effect as a correct answer - the table is not created). I don't see how the given answer and explanation can be considered useful, as they are concerned only with running the code as three separate batches, and I thought it fair to assme that the person who wrote the question would know enough to understand the difference between running something as a single batch and running it as three batches (always assume the best of people unless there is evidence to the contrary is generally a good rule).
I find it amazing that so many people think it a good question. The attempt by one of them to justify it even after the error has been pointed out demonfox (2/10/2013) Well, Let's not lost the question in the wordings; what's the point of three Go Statements , if the statement meant to remove them and then execute as it said which seems say "the author can't have got it wrong because I didn't spot the mistake" just plain silly. It's always just plain silly to say "whats the point is it meant what it said?", the sensible question is "what's the point of saying something doesn't mean what you say?".
It isn't a good question, inn fact it is a terrible question, because it is not asking what the author apparently thought it asked. If it had meant what it said, it would have been a good question.
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
http://es.linkedin.com/in/tomthomsonsoftware
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, March 14, 2013 12:20 PM
Points: 108,
Visits: 206
|
|
binod.soft (2/10/2013) The Statement has three GO syntax which indicates three Batches. Each Go used shows an end of the Batch.
Yes, there's not really any getting round that - however you sometimes learn as much from a badly worded question as a perfectly worded one - you just don't necessarily get your point(s).
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 1:48 AM
Points: 1,112,
Visits: 1,237
|
|
I think, i didn't take it seriously, and i got it wrong. anyway good question.
Keep Learning - Keep Growing !!! http://growwithsql.blogspot.in
Thanks Vinay Kumar
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: 2 days ago @ 6:30 AM
Points: 9,410,
Visits: 6,495
|
|
Hugo Kornelis (2/11/2013)
I'm surprised you didn't know this. Integer is actually the official name; int is an accepted abbreviation. *cough* I have to retract the above. That's what I always thought, but when I went out to find a Books Online reference, I was surprised to see only "int" there. "Integer" is not even mentioned. 
Well, it doesn't help that no-one ever uses Integer and every script generated by SSMS uses int.
How to post forum questions. Need an answer? No, you need a question. What’s the deal with Excel & SSIS?
Member of LinkedIn. My blog at LessThanDot.
 MCSA SQL Server 2012 - MCSE Business Intelligence
|
|
|
|