Inserting Rows Using SELECT INTO

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Inserting Rows Using SELECT INTO

The SELECT INTO statement creates a new table and populates it with the result set of the SELECT. The structure of the new table is defined by the attributes of the expressions in the select list, for example:

SELECT Shippers.*, Link.Address, Link.City,
                   Link.Region, Link.PostalCode
INTO NewShippers
FROM Shippers
     JOIN LinkServer.DB.dbo.Shippers AS Link
       ON (Shippers.ShipperID = Link.ShipperID)

SELECT INTO can be used to combine data from several tables or views into one table. It can also be used to create a new table containing data selected from a linked server.

See Also

SELECT