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 ««12

Go go go? Expand / Collapse
Author
Message
Posted Monday, August 25, 2008 10:27 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, April 27, 2014 6:26 AM
Points: 1,521, Visits: 3,036
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

Post #558267
Posted Monday, August 25, 2008 10:41 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, April 27, 2014 6:26 AM
Points: 1,521, Visits: 3,036
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.
Post #558279
Posted Monday, August 25, 2008 10:55 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
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."
Post #558295
Posted Monday, August 25, 2008 1:09 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: Tuesday, July 8, 2014 12:24 PM
Points: 3,475, Visits: 579
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

Post #558387
Posted Tuesday, August 26, 2008 6:35 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:36 PM
Points: 5,308, Visits: 1,378
Wonderful question...


Post #558809
Posted Monday, January 26, 2009 1:03 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 4:46 AM
Points: 8,573, Visits: 9,078
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
Post #643666
Posted Thursday, June 25, 2009 6:54 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, July 24, 2014 4:28 AM
Points: 1,100, Visits: 4,898
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.
Post #741767
Posted Tuesday, December 11, 2012 3:19 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, July 25, 2014 12:34 AM
Points: 1,888, Visits: 2,326
gr888 question,,
GO GO GO



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1394992
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse