INSERT INTO ... SELECT copies records directly from one table to another. The selected columns must match the destination table in both number and compatible data types.
Businesses frequently copy data into backup tables, archive tables, reporting tables, or staging tables without manually entering records.
Before making major updates, a company copies all employee records into a backup table using INSERT INTO ... SELECT.
INSERT INTO EmployeeBackup
(
EmployeeID,
EmployeeName,
Department,
Salary
)
SELECT
EmployeeID,
EmployeeName,
Department,
Salary
FROM Employees;
Used for backups, ETL processes, data migration, reporting databases, historical archives, and data warehousing.
- Copies data from another table.
- Uses a SELECT statement.
- Column count must match.
- Data types should be compatible.
- Useful for backups.
- Common in ETL processes.
- Reduces manual data entry.
What does INSERT INTO ... SELECT do?
It copies records from one table into another table.
Do source and destination columns need to match?
Yes. They should have the same number of columns and compatible data types.