Forum Moderators: open
SELECT <expression>
<stuff>
GO
SELECT <expression>
<stuff>
GO
And so on. When should/shouldn't I be using the GO statement. Do I use it if I'm doing multiple queries (more than 10) or are there mission critical times when it needs to be used? I'm lost, little help.
--Nick
Multiple line comments ( /* */) cannot include a GO statement
A runtime error such as an arithmetic overflow will stop the remainder of the statements from executing.
Outside of the above, you would use a GO to:
1. determine the scope of local variables
( a local variable declared in one batch
cannot be read in another batch)
2. solve timing problems
(A table cannot be altered and then the
new columns referenced in the same batch)
3. group multiple SELECT statements together
for faster processing (10 SELECT statements
in a batch will process faster than 10
batches of one SELECT each)
Your example of a GO after every statement would create many more batches than necessary.