By: Jeremy Kadlec
Overview
Since we have already mentioned the SELECT command in this INSERT tutorial, let's see how to use the SELECT command to create a new table and populate with data from an existing table.
Explanation
In this example we are creating a new table called dbo.CustomerEmailAddress with only the CustomerID and EmailAddress from the dbo.Customer table. See the code below.
-- 1 - Populate the dbo.CustomerEmailAddress table SELECT CustomerID, EmailAddress INTO dbo.CustomerEmailAddress FROM dbo.Customer; GO -- 2 - Verify the data in the dbo.CustomerEmailAddress table SELECT * FROM dbo.CustomerEmailAddress; GO
Last Update: 9/16/2011