How will you copy the structure of a table without copying the data ?

 Posted by Bharathi Cherukuri on 6/6/2012 | Category: Sql Server Interview questions | Views: 2453 | Points: 40

By using UNIVERSAL FASLE condition like 1=2,A=B....etc.
This is the only method for copying the structure of the table without copying the data.


create table NEWTable AS select * from OLDTABLE where 1=2

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Manof_Light on: 6/7/2012 | Points: 10
give an error in SQL Server.

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.

Posted by: Bharathi Cherukuri on: 6/7/2012 | Points: 10
Try this one..

SELECT * INTO tblNew FROM tblOld WHERE 1=2

Posted by: Jagdishkholiya on: 2/19/2013 | Points: 10
Try this :

SELECT * INTO NEWTable FROM OldTable where 1=2

Login to post response