Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Table by Copying Structure of Existing Table

I am trying to create a new table by copying an existing table in SQL Server 2008 using Management Studio. The existing table contains no data. I am using the following code but am receiving an error for Incorrect Syntax near AS. I am not sure what is wrong here. I am a SQL newb and any help would be appreciated. Thanks.

CREATE TABLE Drop_Centers_Detail
    AS (Select * From Centers_Detail)
like image 881
user234872 Avatar asked May 19 '10 18:05

user234872


1 Answers

like this, however this will not create indexes and constraints

select * into Drop_Centers_Detail
from Centers_Detail
where 1 = 0
like image 132
SQLMenace Avatar answered Sep 20 '22 13:09

SQLMenace