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


What is the result ? (SQLServer 2005)


What is the result ? (SQLServer 2005)

Author
Message
Kangana Beri
Kangana Beri
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1102 Visits: 954
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?
john.arnott
john.arnott
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3598 Visits: 3059
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?
Ian Elliott
Ian Elliott
Old Hand
Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)

Group: General Forum Members
Points: 389 Visits: 971
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. Smile

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 BigGrin), 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.
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)SSC Guru (94K reputation)

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

Cool

Cool
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)
Madhivanan-208264
Madhivanan-208264
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1581 Visits: 476
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
SQL Editor
SQL Editor
SSC Eights!
SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)SSC Eights! (916 reputation)

Group: General Forum Members
Points: 916 Visits: 363
Thanks for this..............
kapil_kk
kapil_kk
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5310 Visits: 2767
good discussion :-Pw00t

_______________________________________________________________
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