Table of Contents

    The SQL SELECT INTO Statement: A Comprehensive Guide

    The SQL SELECT INTO Statement: A Comprehensive Guide

    The SELECT INTO statement copies data from one table into a new table.

    Syntax:

    
    SELECT *
    INTO newtable [IN externaldb]
    FROM oldtable
    WHERE condition;
    

    Copy only some columns into a new table:

    Syntax:

    
    SELECT column1, column2, column3, ...
    INTO newtable [IN externaldb]
    FROM oldtable
    WHERE condition;
    

    SQL SELECT INTO Examples

    The following SQL statement creates a backup copy of Employee:

    
    SELECT * INTO EmployeeBackup1
    FROM Employee;
    

    The following SQL statement uses the IN clause to copy the table into a new table in another database:

    
    SELECT * INTO EmployeeBackup1 IN 'Backup.mdb'
    FROM Customers;
    

    The following SQL statement copies only a few columns into a new table:

    
    SELECT EmployeeName, ContactName INTO EmployeeBackup1
    FROM Employee;