Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Creating Tables


Creating Tables

Author
Message
venkat9.sql
venkat9.sql
SSC Veteran
SSC Veteran (270 reputation)SSC Veteran (270 reputation)SSC Veteran (270 reputation)SSC Veteran (270 reputation)SSC Veteran (270 reputation)SSC Veteran (270 reputation)SSC Veteran (270 reputation)SSC Veteran (270 reputation)

Group: General Forum Members
Points: 270 Visits: 260
I really wasn't sure if I have to 'GO' or not to 'GO' for my answer...I GOed and got it right..So what I learned from this Qotd is whenever there is a doubt just keep GOing ;-)

___________________________________________________________________
If I can answer a question then anyone can answer it..trying to reverse the logic.. Hehe
sestell1
sestell1
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2195 Visits: 3415
(Bob Brown) (2/11/2013)
Sean Lange (2/11/2013)
Here is the original code with the GOs commented out so it will be a single batch.


But the GOs are there.


Even if you ignore the erroneous use of the word 'batch' in the question and leave the GOs in place... the third answer is still not correct because it says that only statements 1 and 3 will run successfully, which is not the case.

It's unfortunate because the wording issues are confusing and distract from the intent of the question.
(Bob Brown)
(Bob Brown)
SSC Eights!
SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)

Group: General Forum Members
Points: 815 Visits: 1145
sestell1 (2/11/2013)

Even if you ignore the erroneous use of the word 'batch' in the question and leave the GOs in place... the third answer is still not correct because it says that only statements 1 and 3 will run successfully, which is not the case.

It's unfortunate because the wording issues are confusing and distract from the intent of the question.


I agree! A truce?
ldorian81
ldorian81
Old Hand
Old Hand (352 reputation)Old Hand (352 reputation)Old Hand (352 reputation)Old Hand (352 reputation)Old Hand (352 reputation)Old Hand (352 reputation)Old Hand (352 reputation)Old Hand (352 reputation)

Group: General Forum Members
Points: 352 Visits: 314
I saw that the the CREATE TABLE and INSERT INTO #Table would conflict therfore running it as one batch (as stated in the Question) would error the whole statement regardless of the GO commands being there or not being there.

The results are the same if you run the whole query as one batch with or without the 'GO' commands.

Therfore the Answer

Only the 1st and 3rd statement will succeed but no rows will be returned.

is wrong!

And the Correct answer should be.

All statements will fail.

If You run the whole query as 1 Batch (as stated!)

If however, you were asked to run the three independantly in the same Query window then the right answer would be.

Only the 1st and 3rd statement will succeed but no rows will be returned.


Poorly wrote question and needs correcting. (oh and give me the point for a correct answer :-D:-P)

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.
Miles Neale
Miles Neale
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2666 Visits: 1694
I have been reading the QODs as of late with a grain of salt. If the wording is correct there is one answer, but given the wording of some of the questions and guessing on the intent the answer is not always as it appears. I guessed at the answer and in doing so I made an assumption.

I assumed that the author was saying "what happens if you include all of the SQL in a batch job or a scheduled script run as a batch job?" THis gives a second meaning to the word batch and made the correct answer correct.

However, I have to agree that GO denotes a batch execution of all previous unexecuted SQL, that is just how it is done. Multiple Go statements are by definition multiple batch executions. If you remove all but the last Go there is a different answer.

But I have to admit that this line of discussion to a rookie, ( and we were all rookies at one time), this discussion is very valuable and educational.

M.

Not all gray hairs are Dinosaurs!
Ed B
Ed B
Mr or Mrs. 500
Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)Mr or Mrs. 500 (594 reputation)

Group: General Forum Members
Points: 594 Visits: 1775
ldorian81 (2/11/2013)
If you put the whole query into SSMS 2008 and run it without removing the 'GO' commands you will still get the same results as shown below.


Msg 2714, Level 16, State 1, Line 18
There is already an object named '#TempQoD' in the database.



.


That appears on the messages tab. The results tab had the table selected with no rows.
Ken Wymore
Ken Wymore
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4422 Visits: 2342
I made the assumption that the author didn't actually understand that GO was a batch separator and was instead focused on the temp table creation process. I hate to make these assumptions but I couldn't see why they would write to run it as one batch when one could not do so without modifying the code supplied. Another flawed QoTD. Thanks for trying.
EL Jerry
EL Jerry
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3914 Visits: 1337
Wording was confusing, however I managed to get it right.
Saludos,

"El" Jerry.

"A watt of Ottawa" - Gerardo Galvan

To better understand your help request, please follow these best practices.
rfreiberg001
rfreiberg001
Old Hand
Old Hand (355 reputation)Old Hand (355 reputation)Old Hand (355 reputation)Old Hand (355 reputation)Old Hand (355 reputation)Old Hand (355 reputation)Old Hand (355 reputation)Old Hand (355 reputation)

Group: General Forum Members
Points: 355 Visits: 617
Since the question didn't ask what version of SQL Server, none of the answers are correct. In SQL 2005, you get an error message, yet you still get one row selected.

Msg 2715, Level 16, State 7, Line 2
Column, parameter, or variable #4: Cannot find data type Date.
Lokesh Vij
Lokesh Vij
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1564 Visits: 1599
I thought the question was straight forward and got that correct. Thanks :-)

~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search