Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 509cf30

Browse files
authored
Merge pull request #1431 from BYHAM/patch-108
GO fixing applies to.
2 parents 941d706 + 77eba3e commit 509cf30

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

docs/t-sql/language-elements/sql-server-utilities-statements-go.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "GO (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "03/14/2017"
4+
ms.date: "04/26/2017"
55
ms.prod: "sql-non-specified"
66
ms.reviewer: ""
77
ms.suite: ""
@@ -27,22 +27,19 @@ ms.author: "rickbyh"
2727
manager: "jhubbard"
2828
---
2929
# SQL Server Utilities Statements - GO
30-
[!INCLUDE[tsql-appliesto-ss2008-xxxx-xxxx-xxx_md](../../includes/tsql-appliesto-ss2008-xxxx-xxxx-xxx-md.md)]
30+
[!INCLUDE[tsql-appliesto-ss2008-all-md](../../includes/tsql-appliesto-ss2008-all-md.md)]
3131

3232
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] provides commands that are not [!INCLUDE[tsql](../../includes/tsql-md.md)] statements, but are recognized by the **sqlcmd** and **osql** utilities and [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] Code Editor. These commands can be used to facilitate the readability and execution of batches and scripts.
3333

3434
GO signals the end of a batch of [!INCLUDE[tsql](../../includes/tsql-md.md)] statements to the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] utilities.
3535

36-
||
37-
|-|
38-
|**Applies to**: [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] ([!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)] through [current version](http://go.microsoft.com/fwlink/p/?LinkId=299658)), [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)].|
36+
3937

4038
![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
4139

4240
## Syntax
4341

4442
```
45-
4643
GO [count]
4744
```
4845

@@ -57,25 +54,27 @@ GO [count]
5754

5855
A [!INCLUDE[tsql](../../includes/tsql-md.md)] statement cannot occupy the same line as a GO command. However, the line can contain comments.
5956

60-
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.
57+
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.
6158

6259
```
63-
USE AdventureWorks2012;
60+
SELECT @@VERSION;
61+
sp_who
6462
GO
63+
```
64+
65+
The scope of local (user-defined) variables is limited to a batch, and cannot be referenced after a `GO` command.
66+
67+
```
6568
DECLARE @MyMsg VARCHAR(50)
6669
SELECT @MyMsg = 'Hello, World.'
6770
GO -- @MyMsg is not valid after this GO ends the batch.
6871
6972
-- Yields an error because @MyMsg not declared in this batch.
7073
PRINT @MyMsg
7174
GO
72-
73-
SELECT @@VERSION;
74-
-- Yields an error: Must be EXEC sp_who if not first statement in
75-
-- batch.
76-
sp_who
77-
GO
78-
```
75+
```
76+
77+
7978

8079
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] applications can send multiple [!INCLUDE[tsql](../../includes/tsql-md.md)] statements to an instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] for execution as a batch. The statements in the batch are then compiled into a single execution plan. Programmers executing ad hoc statements in the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] utilities, or building scripts of [!INCLUDE[tsql](../../includes/tsql-md.md)] statements to run through the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] utilities, use GO to signal the end of a batch.
8180

@@ -115,4 +114,4 @@ SELECT USER_NAME();
115114
GO 2
116115
```
117116

118-
117+

0 commit comments

Comments
 (0)