|
Posted by Damien on 01/05/07 08:19
--CELKO-- wrote:
> SQL Server is weird on this, but each VIEW statement has to be in a
> batch by itself. The reason is that VIEWs can be built on VIEWs, so
> you need to commit the first VIEW to do this.
>
> That also means you cannot end it with a semi-colon and have to have a
> keyword GO instead. That is another weird keyword in SQL Server; it
> says make a batch out of the preceding statements.
Hi Joe,
Since we're picking on your answer here, can I also point out that GO
is a keyword for query analyzer (by default) and for the command line
tools. It is *not* a keyword for SQL Server, and is never sent to the
server.
This becomes obvious if ever you try to comment out a batch of code
that includes GOs. Because Comments are intepreted by SQL Server, but
the GOs are interpreted by the tool, you'll get error messages galore
(unterminated comments, unexpected * found, etc), plus whatever is
batched within the GOs within the commented out block still get
executed.
Damien
[Back to original message]
|