Inserting Data Based on a SELECT Statement

One feature of the INSERT statement that you will use quite a bit is the ability to insert data into a table based on a SELECT statement. This action enables you to add multiple rows into a table very easily. When you INSERT large amounts of data into a table by using a SELECT statement, the entire process is a single transaction. This enables you to roll back the entire thing if something out of the ordinary happens. The process of adding data to a table based off a SELECT statement can be slightly difficult at first. The two main things that you have to remember are that you don't use the VALUES keyword and don't enclose the SELECT statement in parentheses. If you forget either of these, SQL Server ...

Get Writing Stored Procedures for Microsoft SQL Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.