Sunday, February 19, 2012

copy table structure

Hi,
In SQL Server, Is there any DDL available to copy a table structure alone and not the data,
I believe 'SELECT * into new_table from table1' will copy both structure and data as well.
Please advice,
Thanks,
SmithaYou can do:

select top 0 * into new_Table from table1;

--or
select top 0 * into new_Table from table1 where 1=0;

-- or in SQL Server 2005
select top(0) * into new_Table from table1;

No comments:

Post a Comment