SQL Server emergency? Email pinal@sqlauthority.com with URGENT in the subject line.

Create Table From Another Table: What SELECT INTO Copies

To create table from another table in SQL Server, use SELECT INTO with WHERE 1 = 2 or TOP (0) for the structure alone. This post builds a demo table and compares it with its copy column by column. It shows the identity trap, the computed column that becomes plain, and the statements that add keys, defaults and indexes back.

Continue Reading

Partition Switch in SQL Server: Move a Million Rows in a Moment

A partition switch moves a whole partition from one table to another without copying a single row. This post builds a partitioned table with a million rows, switches the January partition out and back in, and shows that only metadata changes. It lists the five errors that stop a switch, with the real message numbers, and ends with the sliding window pattern.

Continue Reading