Microsoft SQL Server 2005 Developer’s Guide- P4:This book is the successor to the SQL Server 2000 Developer’s Guide, which was extremely successful thanks to all of the supportive SQL Server developers who bought that edition of the book. Our first thanks go to all of the people who encouraged us to write another book about Microsoft’s incredible new relational database server: SQL Server 2005. | Chapter 2 Developing with T-SQL 59 The code block that you can see at the top of this listing essentially creates a new table named . This table is based on the rows in the HumanResources .Department table where the DepartmentID is less than or equal to 8. The next code block creates a second new table named using the rows in the table where the DepartmentID is greater than 8. The UNION statement will then take these two results sets and join them back together into a single result set. The results of the union of the table and the table are shown in the following listing. As you can see the UNION operation merged the two tables together back into a single table with the same contents as the original table that was used as a basis to create the other two tables 8 row s affected 8 row s affected DepartmentID Name GroupName 1 Engineering Research and Development 2 Tool Design Research and Development 3 Sales Sales and Marketing 4 Marketing Sales and Marketing 5 Purchasing Inventory Management 6 Research and Development Research and Development 7 Production Manufacturing 8 Production Control Manufacturing 9 Human Resources Executive General and Administration 10 Finance Executive General and Administration 11 Information Services Executive General and Administration 12 Document Control Quality Assurance 13 Quality Assurance Quality Assurance 14 Facilities and Maintenance Executive General and Administration 15 Shipping and Receiving Inventory Management 16 Executive Executive General and Administration 16 row s affected Using Subqueries A subquery is a query that s nested inside of another T-SQL query. Subqueries can be nested within SELECT INSERT UPDATE or DELETE statements. More information about using INSERT UPDATE and DELETE statements is presented later in this chapter. 60 Microsoft SQL Server 2005 Developer s Guide The following example .