Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Still confused about use of GO
Message
 
 
To
04/04/2012 05:59:39
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01540105
Message ID:
01540248
Views:
37
>>I do know that GO can only be used in SSMS and not in the application. But I was not sure where in the SSMS I should use GO between lines like UPDATE. Thank you.
>
>It's there to delimit batches. You may have a long script, which just can't be run all at once. SQL server specifically says that some commands can be run only as first in one batch - the batch being one trip to the server, or one sqlexec() call.
>
>So the script is cut into pieces which can run, and the GO keyword is the delimiter. A piece of script between two GO commands (or the first byte of script and the first GO) is executed in a single call, then the next one, then the next.
>
>You don't really need the GO, if your script doesn't have any of those "must be first" commands. Many M$ script generators insert it just in case, even when in most cases it's not necessary at all. And you can also, if you want to, execute a piece of script by selecting it and pressing F5 - the SMSS (and query analyzer before it) treat the selection as "piece of script to run now".

Thank you for the explanation. Now I just need to see some lines of code that, for example, would need to be run in the SSMS and must have GO.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform