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

What is the result ? (SQLServer 2005) Expand / Collapse
Author
Message
Posted Thursday, September 11, 2008 12:08 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: Thursday, April 10, 2014 3:50 PM
Points: 872, Visits: 952
In SSMS, if you write the statement in 1 line, you get a syntax error:
print 'Hey what''s going on ?';GO 10


But changing it to 2 lines works fine:

print 'Hey what''s going on ?';
GO 10


Can somebody explain why GO preceded by a ; gives error?



Post #568021
Posted Thursday, September 11, 2008 12:44 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:55 AM
Points: 1,520, Visits: 3,035
re: why GO has to be on its own line.

From the BOL help screen....

GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.

SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO.

A Transact-SQL statement cannot occupy the same line as a GO command. However, the line can contain comments.

Users must follow the rules for batches. For example, any execution of a stored procedure after the first statement in a batch must include the EXECUTE keyword. The scope of local (user-defined) variables is limited to a batch, and cannot be referenced after a GO command.


I note that neither the given syntax example nor the example code includes the iteration count parameter. Is this a stealth feature?
Post #568052
Posted Thursday, September 11, 2008 5:19 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, April 17, 2014 4:05 AM
Points: 230, Visits: 767
Lynn Pettis (9/11/2008)
We never eliminate abiguity, just minimize it. As for the QotD, yes, they are a learning tool, but really will it matter tomorrow if you got the answer today right or wrong? What really matters is that you learned something from the question, and sometimes from the ensuing discussion.


Yep I agree about assumptions, I do make them when I have to, but have an "accept no responsibility" disclaimer attached cos I was fed up being blamed for having to make them from other peoples shortcomings and then getting the sharp end when people changed their minds as of course it was my fault for assuming things that others wouldn't tell me; but anyway that's another topic for another time and another place and I only mentioned it cos I wanted to explain where my distaste of assumptions comes from.

And I agree totally about learning something new. It's the reason i'm a member of sites like this as I'm still trying to work my way up. :)

My issue was that I really wanted the ambiguity acknowledged. As you say the points don't matter at all. I'm never going to be right all the time (or even most of it :D), it's just I felt the ambiguity and the possibility that the answer was not completely clear cut was being dismissed.

Sorry if I've caused any offense.
Post #568199
Posted Thursday, September 11, 2008 9:39 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 7:07 AM
Points: 22,507, Visits: 30,223
No offense taken. We both just have different perceptions from reading the question at hand. When the question started with In SQL Server 2005, I just automatically eliminated the use of all SQL Server 2000 tools, even though Query Analyzer will connect and work with SQL Server 2005 databases even though Enterprise Manager won't. Others, did not make that same assumption. Same is true of questions that specify SQL Server 2008. Even though I currently don't have the tools for SQL Server 2008, I will try to answer those questions based on what I know of its tools, not what happens with SQL Server 2005 tools connected to an instance of SQL Server 2008.

Just seems to be the way it should be done.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #568236
Posted Monday, September 22, 2008 1:04 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, January 22, 2014 3:07 AM
Points: 329, Visits: 468
This may be interesting to read
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/05/fun-with-go.aspx




Madhivanan

Failing to plan is Planning to fail
Post #573275
Posted Thursday, July 29, 2010 11:20 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Thursday, April 17, 2014 6:43 AM
Points: 697, Visits: 344
Thanks for this..............
Post #960899
Posted Thursday, December 13, 2012 7:22 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, April 14, 2014 11:50 PM
Points: 1,867, Visits: 2,275
good discussion


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

Add to briefcase «««1234

Permissions Expand / Collapse