Using SELECT statements in batches

You can include one or more SELECT statements in a batch.

The following is a valid batch:

IF EXISTS(	SELECT *
				FROM systable
				WHERE table_name='employee' ) 
THEN
	SELECT	emp_lname AS LastName,
				emp_fname AS FirstName
	FROM employee;
	SELECT lname, fname
	FROM customer;
	SELECT last_name, first_name
	FROM contact;
END IF

The alias for the result set is required only in the first SELECT statement, as the server uses the first SELECT statement in the batch to describe the result set.

A RESUME statement is required following each query to retrieve the next result set.