Programmer's Rules


How to create table and insert rows into it simultaneously in SQL Server

Example of using SELECT INTO in Transact-SQL to create and populate a table

Transact-SQLjob interviewSQL Server70-761

When you want to copy some selected columns and rows from other tables into a new one with Transact-SQL, the solution is to use a SELECT INTO formula.

Permissions to create tables are needed to use this formula.

Generally, the syntax is similar to the following:

The following code shows a real example:

A new table named Person.Names is created. The columns of the new table has the same names, types and nullability as columns selected from the old table.
Tutorial statistics