Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to end the script
Message
 
To
11/06/2008 14:34:54
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01323190
Message ID:
01323214
Views:
10
>>>I want to end the script at some point so the code after it does not run. I would just use CANCEL or RETURN in Forpro.
>>
>>Put GO statement to separate scripts from one another. It doesn't stop it, though, so you can use RETURN command.
>
>If GO doesn't stop the script, what does it do?

I can't write it any better than BOL so here is what it says in BOL:

GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.

SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO.

A Transact-SQL statement cannot occupy the same line as a GO command. However, the line can contain comments.

Users must follow the rules for batches. For example, any execution of a stored procedure after the first statement in a batch must include the EXECUTE keyword. The scope of local (user-defined) variables is limited to a batch, and cannot be referenced after a GO command.
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform