Statement Batch in SQL Server Transact-SQL

Q

What is statement batch in SQL Server Transact-SQL?

✍: FYIcenter.com

A

A statement batch is a group of one or more Transact-SQL statements sent at the same time from an application to SQL Server for execution. SQL Server compiles the statements of a batch into a single executable unit, called an execution plan. The statements in the execution plan are then executed one at a time.

How to define and send a statement batch to SQL Server is depending on the client application you are using. For example:

  • You need to use the GO command in "sqlcmd" tool to end a batch and send it to SQL server.
  • SQL Server Management Studio also uses GO command to separate batches when multiple statements are selected for execution.
  • In ADO, a batch is defined as all the statements entered in the CommandText property of a Command object.

Remember that "GO" is not a Transact-SQL statement. "GO" is a command of the client tool.

 

General Questions on Microsoft SQL Server Transact-SQL

⇒⇒SQL Server Transact-SQL Tutorials

2017-05-29, 356👍, 0💬