GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Database  >  SQL Server
Go To First  |  Previous Question  |  Next Question 
 SQL Server  |  Question 5 of 99    Print  
How will you copy the structure of a table without copying the data?

  
Total Answers and Comments: 15 Last Update: July 03, 2009     Asked by: Beena 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Sridhar
 
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

Above answer was rated as good by the following members:
dhanu_mitra
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
September 21, 2005 01:23:13   #1  
Rahul Tripathi        

RE: How will you copy the structure of a table without...

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


 
Is this answer useful? Yes | No
September 21, 2005 01:25:51   #2  
rahultripathi Member Since: September 2005   Contribution: 22    

RE: How will you copy the structure of a table without...

create table newtable AS select * from oldtable where 1 2

rahultripathi@myway.com


 
Is this answer useful? Yes | No
September 21, 2005 03:07:14   #3  
Shobha Member Since: September 2005   Contribution: 6    

RE: How will you copy the structure of a table without...

but Rahul it's not run at SQL Query Analyzer plze send the query for SQL

Thanks


 
Is this answer useful? Yes | No
September 23, 2005 03:32:22   #4  
rahultripathi Member Since: September 2005   Contribution: 22    

RE: How will you copy the structure of a table without...
Shobha Wrote:

but Rahul it's not run at SQL Query Analyzer plze send the query for SQL

Thanks

Dear Shobha

If your using SQL SERVER please Use this Syntex :-

select * Into NEWTABLE from OLDTABLE where 1 2

PLZ REPLY / query rahultripathi@myway.com


 
Is this answer useful? Yes | No
October 13, 2005 08:23:49   #5  
Ajay Sharma        

RE: How will you copy the structure of a table without...
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!
 
Is this answer useful? Yes | No
July 16, 2006 00:45:21   #6  
Sridhar        

RE: How will you copy the structure of a table without...
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

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
March 30, 2007 07:05:07   #7  
Deependra Singh Bhandari        

RE: How will you copy the structure of a table without...
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
 
Is this answer useful? Yes | No
May 02, 2007 05:18:32   #8  
Omprakash        

RE: How will you copy the structure of a table without...
Hi All



SELECT TOP 0 * INTO Test1 FROM Test



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

 
Is this answer useful? Yes | No
June 05, 2007 10:43:24   #9  
DJ        

RE: How will you copy the structure of a table without...
SELECT * INTO newtable FROM oldtable WHERE 1 2
 
Is this answer useful? Yes | No
January 09, 2008 15:27:13   #10  
chihoo2003 Member Since: January 2008   Contribution: 4    

RE: How will you copy the structure of a table without copying the data?
select * into NEW_TABLE from SOURCE_TABLE where 1 2
 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape