How will you copy table structure using an SQL Query?
This was the question I was asked in one of the inteview, after hearing this I first thought, Is there a way to copy only the table structure. I only knew the query to copy data along with its structure and take backup of tables.And I answered the same.
Later after finishing my interview I went home and googled on this, and was really surprised when I found these two queries.
So thought of sharing this.
Below are the queries which will only copy the table structure.
select * INTO newtable from oldtable where 1=2
select Top 0 * into newtable from [oldtable]
Hope this will help lot of them who are like me ![]()
Enjoy.

create table newtable as select * from old_table where old_table_column_name=’value does not exist’;
This also copies the tabke structure if the value ‘value does not exist’ does not exist in the column old_table_column_name