Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

GO Part 1 Expand / Collapse
Author
Message
Posted Thursday, September 6, 2012 10:38 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 1:43 PM
Points: 3,464, Visits: 1,803
Comments posted to this topic are about the item GO Part 1

Kenneth Fisher
I strive to live in a world where a chicken can cross the road without being questioned about its motives.
--------------------------------------------------------------------------------
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Link to my Blog Post --> www.SQLStudies.com
Post #1355723
Posted Thursday, September 6, 2012 11:14 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:24 AM
Points: 962, Visits: 2,190
Awesome. :) thank you Kenneth.

1. it will insert 1 record - FROM INSERT INTO
2. it will insert 1 record - But the count in table is 2 - from INSERT..SELECT
3. Iteration1- Inserts 2 records - the count is 4
4. Iteration2- Inserts 4 records - the count is 8
5. Iteration3- Inserts 8 records - the count is 16
6. Iteration4- Inserts 16 records - the count is 32
AND
7. Iteration5- Inserts 32 records - the count is 64

Now this is where I went wrong, actually the #2's GO is the valid first iteration, so it stops at #6 which actually completes 5 iterations. (#7 is not valid)

(so simple and yet I messed up )

(Just wanted to say Thank you to all, this is been the best learning experience apart from the regular routine )


ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
Post #1355739
Posted Thursday, September 6, 2012 11:15 PM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Sunday, June 29, 2014 11:26 PM
Points: 1,481, Visits: 1,960
Worthless question because of the fact that you add something that doesnt really relate to the question. The key part in the question is the "GO 5" part. And by adding the select from the table in the insert you make the "GO 5" part secondary.

/T
Post #1355741
Posted Thursday, September 6, 2012 11:34 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:29 PM
Points: 12,966, Visits: 10,742
tommyh (9/6/2012)
Worthless question because of the fact that you add something that doesnt really relate to the question. The key part in the question is the "GO 5" part. And by adding the select from the table in the insert you make the "GO 5" part secondary.

/T


Why does it make GO 5 secondary?
The GO 5 combined with the SELECT makes the insert a power of two, which is a nice twist on the question. The question still deals with the subject: a batch is repeated 5 times because it's followed by GO 5.

@Kenneth: very nice question to end the week.




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
Post #1355747
Posted Friday, September 7, 2012 12:41 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, August 22, 2013 9:13 AM
Points: 496, Visits: 601
Good question, thanks, and how annoying that I couldn't spot the twist until it was too late.

Lesson: Never answer QOTW before 7am.


---

Note to developers:
CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
So why complicate your code AND MAKE MY JOB HARDER??!

Want to get the best help? Click here http://www.sqlservercentral.com/articles/Best+Practices/61537/ (Jeff Moden)
My blog: http://uksqldba.blogspot.com
Visit http://www.DerekColley.co.uk to find out more about me.
Post #1355777
Posted Friday, September 7, 2012 1:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:18 PM
Points: 7,701, Visits: 9,431
Good question.

Two days in a row now answering early morning has proved that I shouldn't do it. Yesterday I couldn't add. Today I can't multiply (or at least I get 1*2*2*2*2*2 = 6). Evidently my brain doesn't start functioning until it has been fed and watered.


Tom
Post #1355797
Posted Friday, September 7, 2012 1:49 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:18 PM
Points: 7,701, Visits: 9,431
L' Eomot Inversé (9/7/2012)
Good question.

Two days in a row now answering early morning has proved that I shouldn't do it. Yesterday I couldn't add. Today I can't multiply (or at least I get 1*2*2*2*2*2 = 6). Evidently my brain doesn't start functioning until it has been fed and watered.


Edit: I've just noticed a failure to normalise even to 1 NF in my comment. Two days in a row is clearly a repeating group.


Tom
Post #1355800
Posted Friday, September 7, 2012 2:39 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 11:09 AM
Points: 3,070, Visits: 3,299
Good question

Nearly missed the 5 after the last go - then had to remember why it was significant

Got my point though


-------------------------------
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
Post #1355821
Posted Friday, September 7, 2012 3:10 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 5:28 AM
Points: 1,150, Visits: 1,090
Nice question.

I can see both sides of the discussion above re. whether it was "worthless" or not. I do think the head-scratching (for me, at least) over how many records would be in the table takes away from whether "GO x" is valid or not.

Then again, "Is GO x valid T-SQL?" would be a boring question.

Post #1355841
Posted Friday, September 7, 2012 3:10 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, August 27, 2013 4:28 AM
Points: 1,248, Visits: 779
What a fun question, thanks.

_____________________________________________________________________
"The difficult tasks we do immediately, the impossible takes a little longer"
Post #1355842
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse