Create a Table From a SQL Statement

You can create a copy of a table using the SELECT INTO command.

SELECT * INTO TABLE2 FROM TABLE1

You can also join two or more tables and create a new table from the joined tables.

SELECT * INTO TABLE3 FROM TABLE1 a LEFT OUTER JOIN TABLE2 b ON a.field1 = b.field5

The newly created table will not have a primary key even if the existing table or tables do have a primary key.

About

Over 27 years programming experience 17 years Oracle SQL/Stored Procedure programming Over 17 years SQL 2000/2005/2008/2012/2016 Server SQL/Stored Procedure programming Over 25 years Visual Basic 3.0/4.0/5.0/6.0/.Net/2003/2005/2008/2010/2015/2019 Over 19 years ASP.Net Over 17 years Visual C# Over 25 years Microsoft Office and VBA HTML JAVA COBOL EASYTRIEVE FORTRAN

Tagged with: , , , , , ,
Posted in SQL Server

Leave a comment