The Statement has three GO syntax which indicates three Batches. Each Go used shows an end of the Batch. I have shown below each of the GO with their end of batches comments.
But As per your question the statement should be executed in a single Batch in which case One has to remove all the GO syntax to execute the whole Query in a single Batch. And hence "Option 2 : All statement should fail" must be the right answer.
The Error must be :--
Msg 2714, Level 16, State 1, Line 18
There is already an object named '#TempQoD' in the database.
Where as if you execute the whole statement with all GO syntax as it is .. In that case the Answer must be option 3.
-- Statement 1
Create Table #TempQoD
, Question varChar(max)
, Answer varChar(max)
, PublishDate Date
Go--End of first batch
-- Statement 2
1 As [RowId]
, 'True or False: The HAVING clause is the 4th phase of logical query processing?' As [Question]
, 'True: 1-FROM, 2-WHERE, 3-GROUP BY, 4-HAVING, 5-SELECT, 6-ORDER BY.' As [Answer]
, '15 Jan 2013' As [PublishDate]
Go--End of 2nd Batch
-- Statement 3
Select * From #TempQoD;
Drop Table #TempQoD;
GO--End Of third batch
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
What will the outcome be after running all the following statements as 1 batch?
All the following statements, means Including Go ..
nice and simple , basics refreshed with a good question ...
thanks for the question
Wondering what I would do next , when I am done with this one