How to programmatically copy a table in SQL Server, without the data?

copy, database, sql-server, sql-server-2005

Solution

select * into new_table from old_table where 1=0

Execute the above command programmatically.

Problem

I need to copy a table I already I have in a SQL server database, but I don't need the data contained in the source table. The examples I found only involve copying the data. Here are the details: - Copy the table structure only, not the data. - Source and target tables are in the same database. - Target table does not exist yet. - Need to do this programmatically - It would be nice to have any related properties of the table/columns be copied as well.

Original source