Check for Errors

If a select into statement fails after creating a new table, the table is not automatically dropped or the first data page deallocated. This means that any rows inserted on the first page before the error occurred remain on the page. Check the value of the @@error global variable after a select into statement to be sure that no error occurred.

select into is a two-step operation. The first step creates the new table and the second step inserts the specified rows into the table. Because select into operations are not logged, you cannot issue them within user-defined transactions, and you cannot roll them back.

If an error occurs from a select into operation, use drop table to remove the new table, then reissue the select into statement.