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


Go go go?


Go go go?

Author
Message
john.arnott
john.arnott
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1476 Visits: 3059
I thank David Dresser for a good job parsing this out. I tried making it slightly more coder-friendly by renaming the proc "JO" and the variable "KO". I then found that all but the first delimiter "Go" statements didn't seem to be needed at all.
CREATE PROC JO @KO int=NULL AS SELECT @KO
GO
JO;
GO 3
--GO
EXECUTE('JO 3')
GO 3
--GO
DROP PROC JO
--GO


john.arnott
john.arnott
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1476 Visits: 3059
Posts from Anders and webrunner point to how this script uses a new feature in SSMS not available in SQL 2000 QM. The
Go 3

syntax to run something multiple times is not available in QM.

This raises a red flag about testing. The script works fine in SSMS against a SQL 2000 database. This implies that even in a SQL2005 db, it may not work from a program or in a stored procedure.

I've already burned a half-hour on this and have too much to do today, so will leave the resolution of that question to others.
RBarryYoung
RBarryYoung
SSCrazy Eights
SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)

Group: General Forum Members
Points: 9456 Visits: 9517
john.arnott (8/25/2008)
This raises a red flag about testing. The script works fine in SSMS against a SQL 2000 database. This implies that even in a SQL2005 db, it may not work from a program or in a stored procedure.


No it certainly will not. "GO" has always been a client interface feature. It does not work from a program or from a stored procedure and never has. Nor did the question imply that it would, it did specifically say "from SSMS".

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Yelena Varshal
Yelena Varshal
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3480 Visits: 593
GO should never be used as identifier.
http://msdn.microsoft.com/en-us/library/ms189822.aspx
Reserved Keywords (Transact-SQL)

This is not T-SQL keyword now but is on the list on ODBC keywords (second list in the referenced article) and on the third list of the future T-SQL keywords. This article says: "Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using delimited identifiers." About Future Keywords the article says: "The following keywords could be reserved in future releases of SQL Server as new features are implemented. Consider avoiding the use of these words as identifiers."


Regards,
Yelena Varshal

Anipaul
Anipaul
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6287 Visits: 1407
Wonderful question...



TomThomson
TomThomson
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: 10791 Visits: 12026
It threw me. I assumed SSMS would behave the same way as isqlw so gave the wrong answer. I'm inclined to consider the SMSS behaviour a bug, as making sense out of using "go" as an identifier is just making it easier to write obscure bugs - but in fact SQLS 2000 isqlw is just as bad as small adjustments to the script can demonstrate.

Tom

jts2013
jts2013
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1176 Visits: 5009
That's what I like about QotD - the simplest questions are often the most thought provoking!

This definitely proves you should be careful what identifier names you choose.
kapil_kk
kapil_kk
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2447 Visits: 2763
gr888 question,,
GO GO GO :-P

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
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