Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1094

When to Use GO

From Gene Wirchenko <genew@ocis.net>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject When to Use GO
Date 2012-05-30 14:21 -0700
Organization A noiseless patient Spider
Message-ID <2q1ds719sl2jcedv0shaif16dvksgigkds@4ax.com> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


Dear SQLers:

     I am somewhat confused about when to use GO.  I would like to
avoid it where possible, that is, I would prefer to make my batches as
big as possible.  Trying to find out when GO can be omitted is a bit
of an adventure.

     I have done Web searching to find an answer, but there is not
enough detail, as in, for example:
          http://msdn.microsoft.com/en-us/library/ms188037.aspx

     I have a script where I very early delete the database and
recreate it.  In one recent problem area, I create a procedure.  It
has a GO in front of it, because stored procedures have to be first in
a batch.  Fine.  If I then follow with a CREATE TABLE in the same
batch, I get an error that seems to indicate that the CREATE TABLE has
been included in the procedure.  If I put a GO just after the
procedure, I do not have this problem.

     What am I missing or misunderstanding?

     (I am now putting each of my CREATE PROCEDURE statements (and the
procedure) in its own batch delimited by GO at both the beginning and
the end.  This is a bit cargo cult, but it works.)

     When exactly is GO required?

Sincerely,

Gene Wirchenko

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

When to Use GO Gene Wirchenko <genew@ocis.net> - 2012-05-30 14:21 -0700
  Re: When to Use GO Erland Sommarskog <esquel@sommarskog.se> - 2012-05-31 07:29 +0000
    Re: When to Use GO Gene Wirchenko <genew@ocis.net> - 2012-05-31 10:07 -0700
      Re: When to Use GO Erland Sommarskog <esquel@sommarskog.se> - 2012-05-31 22:26 +0200
        Re: When to Use GO Gene Wirchenko <genew@ocis.net> - 2012-06-01 09:41 -0700
          Re: When to Use GO Erland Sommarskog <esquel@sommarskog.se> - 2012-06-01 23:23 +0200
            Re: When to Use GO Gene Wirchenko <genew@ocis.net> - 2012-06-03 19:36 -0700
  Re: When to Use GO "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2012-05-31 06:45 -0400

csiph-web