Home >Database >Mysql Tutorial >How to Correctly Create a Table from SELECT Query Results in SQL Server 2008?

How to Correctly Create a Table from SELECT Query Results in SQL Server 2008?

Patricia Arquette
Patricia ArquetteOriginal
2025-01-17 21:57:11684browse

How to Correctly Create a Table from SELECT Query Results in SQL Server 2008?

Creating a Table from SELECT Query Results in SQL Server 2008

Encountering the "Incorrect syntax near the keyword 'AS'" error while trying to create a table using CREATE TABLE temp AS SELECT ... in SQL Server 2008? This signifies an incompatibility with the syntax.

The correct approach in SQL Server 2008 involves this syntax:

<code class="language-sql">SELECT * INTO new_table FROM old_table;</code>

This command generates a new table named "new_table," mirroring the structure and data of "old_table." Importantly, "old_table" remains unchanged.

The above is the detailed content of How to Correctly Create a Table from SELECT Query Results in SQL Server 2008?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn