Home Products Support Sales Corporate
Products
Performance Monitor
Database Compare
Database Manager
Job Scheduler






Home > Teratrax Database Manager > Help > Working with SQL Batches and Statements

Working with SQL Batches and Statements

The Editor pane in the SQL Query window allows you to write SQL statements and batches and execute them against the database server you are connected to. You can execute a complete script or only selected SQL statements. To execute a complete script, create or open the script in the Editor pane then press F5. To execute only selected SQL statements, highlight the lines of code in the Editor pane then press F5.

SQL Statements vs. Batches

A SQL statement is a single SQL command (for example, SELECT * FROM table1 or SET NOCOUNT ON). A batch on the other hand, is a number of SQL statements sent to the server for execution as a whole unit. The statements in the batch are compiled into a single execution plan. Batches are separated by the GO command.

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.

The GO Command

GO is not a Transact-SQL statement; it is a command recognized by SQL utilities and Teratrax Database Manager to signal the end of a batch of SQL statements. Teratrax Database Manager interprets GO as a signal that it should send the current batch of SQL statements to the server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the script if this is the first GO. If the last batch does not include a GO at the end, one will be added by Teratrax Database Manager.

A SQL statement cannot occupy the same line as a GO command. GO has to be the only command in the line.

Session Configuration (SET Options)

These are default settings for SET options for all ad-hoc queries in the SQL Query window:

Option

Default Setting

SET NOCOUNT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_DEFAULTS ON
SET ARITHABORT ON
SET ANSI_NULLS ON
SET ANSI_NULL_DFLT_ON ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET CURSOR_CLOSE_ON_COMMIT OFF
SET IMPLICIT_TRANSACTIONS OFF
SET QUOTED_IDENTIFIER ON
 
Contact Us

Teratrax Sales


Technical Support


Testimonials



Product Links
Features

Help File

How to Buy

Product Upgrades

Volume Licensing


Related Links
Troubleshooting connections

Disaster recovery plan: Backup types

Automate archival of daily SQL Server backups
Privacy Statement License Agreement Articles Site Map         Copyright © 2002-2008 Teratrax Inc. All rights reserved.