INSERT SELECT allows rows returned by a SELECT statement to be inserted into an existing table. The selected columns must be compatible with the destination table.
It is useful for moving, copying, transforming, or archiving data between tables without manually inserting every row.
A company can copy active employees from an Employees table into an ActiveEmployees table.
INSERT INTO ActiveEmployees
(EmployeeID, EmployeeName, Department)
SELECT
EmployeeID,
EmployeeName,
Department
FROM Employees
WHERE Status = 'Active';
INSERT SELECT is commonly used in ETL processes, data migration, staging, archiving, reporting, and data transformation.
- INSERT SELECT copies query results into a table.
- The destination table must already exist.
- Column types must be compatible.
- WHERE can control which records are copied.
- It is useful for data migration and ETL.
What is INSERT SELECT?
INSERT SELECT inserts rows returned by a SELECT query into another table.
Where is INSERT SELECT commonly used?
It is commonly used for data migration, ETL, archiving, staging, and copying filtered records.