> For the complete documentation index, see [llms.txt](https://gyansetu-sql.gitbook.io/sql-programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-sql.gitbook.io/sql-programming/sql-database/sql-select-into-statement.md).

# SQL SELECT INTO Statement

### The SQL SELECT INTO Statement

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

#### SELECT INTO Syntax

Copy all columns into a new table:

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

Copy only some columns into a new table:

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

The new table will be created with the column-names and types as defined in the old table. You can create new column names using the AS clause.

### SQL SELECT INTO Examples

The following SQL statement creates a backup copy of Customers:

```sql
SELECT * INTO CustomersBackup2017
FROM Customers;
```

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

```sql
SELECT * INTO CustomersBackup2017 IN 'Backup.mdb'
FROM Customers;
```

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

```sql
SELECT CustomerName, ContactName INTO CustomersBackup2017
FROM Customers;
```

The following SQL statement copies only the German customers into a new table:

```sql
SELECT * INTO CustomersGermany
FROM Customers
WHERE Country = 'Germany';
```

**Tip:** SELECT INTO can also be used to create a new, empty table using the schema of another. Just add a WHERE clause that causes the query to return no data:

```sql
SELECT * INTO newtable
FROM oldtable
WHERE 1 = 0;
```

\
\
\
\
\
\ <br>
