What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 4471 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > SQL Server Interview Questions > How will you copy the structure of a tab ...

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

Interview question and answer by: Bharathi Cherukuri | Posted on: 6/6/2012 | Category: SQL Server Interview questions | Views: 928 | | Points: 40


Answer:

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.

Example:

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

Asked In: Many Interviews | Alert Moderator 
Found interesting? Add this to:


 Responses

Posted by: Manof_Light | Posted on: 07 Jun 2012 09:39:15 AM | Points: 10 | Alert Moderator 

give an error in SQL Server.


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


Posted by: Bharathi Cherukuri | Posted on: 07 Jun 2012 09:43:39 AM | Points: 10 | Alert Moderator 

Try this one..

SELECT * INTO tblNew FROM tblOld WHERE 1=2



Regards,
Bharathi

Posted by: Jagdishkholiya | Posted on: 19 Feb 2013 02:35:42 AM | Points: 10 | Alert Moderator 

Try this :

SELECT * INTO NEWTable FROM OldTable where 1=2



>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from Bharathi Cherukuri

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 11:14:10 PM