Follow these guidelines when using UNION with other Transact-SQL statements:
- The first query in the UNION statement can contain an INTO clause that creates a table to hold the final result set. Only the first query can use an INTO clause. If it appears anywhere else, Microsoft® SQL Server™ 2000 displays an error message. Also, remember that if the select into/bulkcopy option is not set, SELECT INTO can create only temporary tables.
- ORDER BY and COMPUTE clauses to define the order of the final results or compute summary values are allowed only at the end of the UNION statement. They cannot be used within the individual queries that make up the UNION statement.
- GROUP BY and HAVING clauses can be used within individual queries only; they cannot be used to affect the final result set.
- The UNION operator can be used within an INSERT statement.
- The FOR BROWSE clause cannot be used in statements involving the UNION operator.