SQL Snippets: SELECT INTO

Microsoft SQL ServerThis post is part of the series on SQL Snippets.

I occasionally need to make a backup of a SQL table and all rows within; while you can create a table and insert the content, this is the long way of doing. Instead you can use SELECT INTO to both create a table with the correct columns and also to copy the data.

In the below example I am creating a new table suffixed with the date; the first highlighted section is the new destination table to be created and the second the source table:

SELECT *
INTO IV00101_20210910
FROM IV00101