SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


GO Part 1


GO Part 1

Author
Message
Kenneth Fisher
Kenneth Fisher
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10847 Visits: 2115
Comments posted to this topic are about the item GO Part 1

Kenneth Fisher
I was once offered a wizards hat but it got in the way of my dunce cap.
--------------------------------------------------------------------------------
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
Raghavendra Mudugal
Raghavendra Mudugal
SSCertifiable
SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)

Group: General Forum Members
Points: 5010 Visits: 2958
Awesome. Smile 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 :w00tSmile

(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.
tommyh
tommyh
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3708 Visits: 2000
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
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (124K reputation)SSC Guru (124K reputation)SSC Guru (124K reputation)SSC Guru (124K reputation)SSC Guru (124K reputation)SSC Guru (124K reputation)SSC Guru (124K reputation)SSC Guru (124K reputation)

Group: General Forum Members
Points: 124937 Visits: 13344
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?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
derek.colley
derek.colley
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4062 Visits: 603
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??!Crazy

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.

Tom Thomson
Tom Thomson
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44256 Visits: 13014
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. Doze

Tom

Tom Thomson
Tom Thomson
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44256 Visits: 13014
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. Doze


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. Rolleyes

Tom

Stuart Davies
Stuart Davies
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10248 Visits: 4861
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 questionThere 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
Michael Lysons
Michael Lysons
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3133 Visits: 1497
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.

:-)
DugyC
DugyC
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2128 Visits: 779
What a fun question, thanks.

_____________________________________________________________________
"The difficult tasks we do immediately, the impossible takes a little longer"
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