Click here to monitor SSC
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
ALZDBA
ALZDBA
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 6970 Visits: 8839
Comments posted to this topic are about the item What is the result ? (SQLServer 2005)

Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution" :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
Ian Scarlett
Ian Scarlett
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1420 Visits: 6255
What happens seems to depend on the SQL Client/Options in use, rather than which version of SQL is at the back end.

The script executes 10 times if I run it in Management Studio, but...

When I run it in Query Analyser (against a SQL 2005 instance), I get an error:-

Server: Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'GO'.



Pires-502779
Pires-502779
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 55
probably Query Analyser doesn't recognize GO [count] syntax.

That proves that Query Analyser has it own syntax validation!
ALZDBA
ALZDBA
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 6970 Visits: 8839
Keep in mind SSMS has some issues with e.g. char(13) resulting in a "syntax error near ...."

And off course you'll need to have the default 'go' for batch separator in your ssms settings.

Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution" :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
skyline666
skyline666
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 229
ALZDBA (9/10/2008)
Keep in mind SSMS has some issues with e.g. char(13) resulting in a "syntax error near ...."

And off course you'll need to have the default 'go' for batch separator in your ssms settings.


Im sorry but no, that is not asked in the question. The question asks what that piece of code does, and the result is:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'GO'.

I was going to choose the correct answer before I tested just to see what does happen, I should of done that as I would of got the answer "correct".
Pires-502779
Pires-502779
SSC Journeyman
SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)SSC Journeyman (78 reputation)

Group: General Forum Members
Points: 78 Visits: 55
skyline666 (9/10/2008)
ALZDBA (9/10/2008)
Keep in mind SSMS has some issues with e.g. char(13) resulting in a "syntax error near ...."

And off course you'll need to have the default 'go' for batch separator in your ssms settings.


Im sorry but no, that is not asked in the question. The question asks what that piece of code does, and the result is:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'GO'.

I was going to choose the correct answer before I tested just to see what does happen, I should of done that as I would of got the answer "correct".


In my case, it results in the batch run 10 times. I tested in my local instalation, with the default setting.

Probably you have some kind of customization that changed the setting for default batch seperator?

Example: If i change default separator to ";" got Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near 'GO'.
ALZDBA
ALZDBA
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 6970 Visits: 8839
You need to use SSMS (SQL 2005) to get the result aimed for with the question.
Apparently it's SSMS that puls this trick !

Indeed With Query Analyser, you'll get the syntax error.


-- Query analyser SQL2000
Server: Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'go'.



-- SSMS 2005
Beginning execution loop
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Hey what's going on ?
Batch execution completed 10 times.


Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution" :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
Satya-571308
Satya-571308
SSC-Enthusiastic
SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)

Group: General Forum Members
Points: 103 Visits: 25
This is the right way to execute the statement without using the counter.
jim.powers
jim.powers
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1343 Visits: 839
I for one, guessed wrong but I wanted to verify my answer before I submitted it. So, I highlighted and copied the code to SSMS and got the error, confirming my guess. When I was told I had the incorrect answer, I went back to SSMS and discovered that the two lines of code were mashed together on a single line:

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



This produced the error. However, when I separated it to two lines, it did work as expected by the question's author:

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


amitchauhanrana
amitchauhanrana
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 91
In response to:
-- Query analyser SQL2000
Server: Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'go'.


Hi,
you are right, this technique does not works in SQL 2000. Its works version SQL 2005 and above and same statement works in sqlcmd without any error. It repeats the batch no of times as integer value mentioned after GO statement.
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