Skip to content

Commit c6822de

Browse files
committed
Refine wording and formatting in 3-describe-batches.md for improved score
1 parent 1133ebe commit c6822de

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

learn-pr/wwl-data-ai/get-started-transact-sql-programming/includes/3-describe-batches.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
T-SQL batches are collections of one or more T-SQL statements that are submitted to SQL Server by a client as a single unit. SQL Server operates on all the statements in a batch at the same time when parsing, optimizing, and executing the code.
22

3-
If you're a report writer who typically writes queries using SELECT statements and not procedures, it's still important to understand batch boundaries. These boundaries will affect your work with variables and parameters in stored procedures and other routines. For example, a variable must be declared in the same batch in which it's referenced. It's important, therefore, to recognize what is contained in a batch.
3+
If you're a report writer who typically writes queries using `SELECT` statements and not procedures, it's still important to understand batch boundaries. These boundaries affect your work with variables and parameters in stored procedures and other routines. For example, a variable must be declared in the same batch in which it's referenced. It's important, therefore, to recognize what is contained in a batch.
44

5-
Batches are delimited by the client application. How you mark the end of a batch depends on the settings of your client. For Microsoft clients including SQL Server Management Studio (SSMS) and SQLCMD the keyword is GO.
5+
Batches are delimited by the client application. How you mark the end of a batch depends on the settings of your client. For Microsoft clients including SQL Server Management Studio (SSMS) and SQLCMD the keyword is `GO`.
66

7-
In this example, there are two distinct batches each terminated with a GO:
7+
In this example, there are two distinct batches each terminated with a `GO` statement:
88

99
```sql
1010
CREATE NEW <view_name>
@@ -17,16 +17,16 @@ GO
1717

1818
The batch terminator **GO** isn't a T-SQL keyword, but is one recognized by SSMS to indicate the end of a batch.
1919

20-
When working with T-SQL batches, there are two important considerations to keep in mind:
20+
Keep two important considerations in mind when you work with T-SQL batches:
2121

22-
- Batches are boundaries for variable scope, which means a variable defined in one batch may only be referenced by other code in the same batch
23-
- Some statements, typically data definition statements such as CREATE VIEW, CREATE FUNCTION, and CREATE PROCEDURE may not be combined with others in the same batch.
22+
- Batches are boundaries for variable scope, which means a variable defined in one batch can only be referenced by other code in the same batch
23+
- Some statements, typically data definition statements such as `CREATE VIEW`, `CREATE FUNCTION`, and `CREATE PROCEDURE` can't be combined with others in the same batch.
2424

2525
## Working with batches
2626

27-
A batch is a collection of T-SQL statements submitted to SQL Server for parsing and execution. Understanding how batches are parsed will be useful in identifying error messages and behavior. When a batch is submitted by a client, such as when you press the Execute button in SSMS, the batch is parsed for syntax errors by the SQL Server engine. Any errors found will cause the entire batch to be rejected; there will be no partial execution of statements within the batch.
27+
A batch is a collection of T-SQL statements submitted to SQL Server for parsing and execution. Understanding how batches are parsed is useful in identifying error messages and behavior. When a batch is submitted by a client, such as when you press the Execute button in SSMS, the batch is parsed for syntax errors by the SQL Server engine. Any errors found cause the entire batch to be rejected; there is no partial execution of statements within the batch.
2828

29-
If the batch passes the syntax check, then SQL Server runs other steps, resolving object names, checking permissions, and optimizing the code for execution. Once this process completes and execution begins, statements succeed or fail individually. This is an important contrast to syntax checking. When a runtime error occurs on one line, the next line may be executed, unless you've added error handling to the code.
29+
If the batch passes the syntax check, then SQL Server runs other steps, resolving object names, checking permissions, and optimizing the code for execution. Once this process completes and execution begins, statements succeed or fail individually. This is an important contrast to syntax checking. When a runtime error occurs on one line, the next line can still execute, unless you add error handling to the code.
3030

3131
For example, the following batch contains a syntax error:
3232

@@ -43,14 +43,14 @@ Msg 102, Level 15, State 1, Line 1
4343
Incorrect syntax near 'VALUE'.
4444
```
4545

46-
The error occurred in line 1, but the entire batch is rejected, and execution doesn't continue with line 2. Even if each of the INSERT statements were reversed and the syntax error occurred in the second line, the first line wouldn't be executed because the entire batch would be rejected.
46+
The error occurred in line 1, but the entire batch is rejected, and execution doesn't continue with line 2. Even if each of the `INSERT` statements were reversed and the syntax error occurred in the second line, the frontline wouldn't be executed because the entire batch would be rejected.
4747

48-
Using the previous example, this batch doesn't contain an error:
48+
In contrast, this corrected batch doesn't contain an error:
4949

5050
```sql
5151
INSERT INTO dbo.t1 VALUES(1,2,N'abc');
5252
INSERT INTO dbo.t1 VALUES(2,3,N'def');
5353
GO
5454
```
5555

56-
In the previous samples, we've used INSERT statements rather than SELECT because it's more common for modification statements to be grouped in batches than SELECT statements.
56+
The previous samples use `INSERT` statements rather than `SELECT` because modification statements are more commonly grouped in batches.

0 commit comments

Comments
 (0)