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

Questions by Beena   answers by Beena

Showing Answers 1 - 48 of 48 Answers

Rahul Tripathi

  • Sep 21st, 2005
 

There is one method for copying the structure of table without copying the data is

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

 rahultripathi@myway.com

  Was this answer useful?  Yes

Ajay Sharma

  • Oct 13th, 2005
 

I think this should be more appropriate: Create table as select * from where 1=2;Here only the structure of the old table is copied and all the constraints imposed on the old table are not copied in the new table.This you can check by writing on SQL PROMPTSQL > desc SQL> desc Thanks!

  Was this answer useful?  Yes

Sridhar

  • Jul 16th, 2006
 

This interview questions are belongs to SQL Server and people are giving answers to Oracle. Please be sure to understand the question and give the answer. Wrong answer may spoil a person interview. Here is the right answer
Without Data : select * into temp2 from temp where 1=2
With Data : select * into temp2 from temp
Regards
Sridhar

Deependra Singh Bhandari

  • Mar 30th, 2007
 

create table NEWTable AS select * from OLDTABLE where 1=2can u used this command in Sql-Server -2005, i have used id but it is not workingwe can used this method as followingselect column name,columnname into newtablename from oldtablename where 1=2

  Was this answer useful?  Yes

Omprakash

  • May 2nd, 2007
 

Hi All


SELECT TOP 0 * INTO Test1 FROM Test


The above query creates only structure. This works in SQL Server 2000 and 2005 also.

  Was this answer useful?  Yes

DJ

  • Jun 5th, 2007
 

SELECT * INTO newtable FROM oldtable WHERE 1=2

  Was this answer useful?  Yes

bugeye

  • Mar 14th, 2008
 

Right click table in SSMS > Script Table as > Create
Your question of "copy" infers that you want all the constraints.  The example that you give doesn't fill the requierments.  As you want the structure you would als want the constraints.

  Was this answer useful?  Yes

Piyush

  • Nov 24th, 2014
 

Anyone please explain me why  " Where  1=2; "

  Was this answer useful?  Yes

sangita gupta

  • Nov 26th, 2014
 

In the where statement we can write false condition which never true..

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions