Geeks Talk

Prepare for your Next Interview




copy the Table Structure

This is a discussion on copy the Table Structure within the SQL Server forums, part of the Databases category; Hi I want to copy the structure & all constrains of one table into other table. There is any Direct query is there without using Sql Scirpt???...


Go Back   Geeks Talk > Databases > SQL Server

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 06-11-2007
Contributing Member
 
Join Date: Jun 2007
Location: Bangalore
Posts: 32
Thanks: 3
Thanked 20 Times in 5 Posts
vcyogi is on a distinguished road
copy the Table Structure

Hi
I want to copy the structure & all constrains of one table into other table.

There is any Direct query is there without using Sql Scirpt???
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-16-2007
Expert Member
 
Join Date: May 2006
Location: New York, USA
Posts: 118
Thanks: 0
Thanked 6 Times in 4 Posts
RyanJames is on a distinguished road
Re: copy the Table Structure

You have a function called as copy function in SQL server which you can use to copy the structure and all constrains of one table into other table. If you want to make a clone of the same table with structure, constraints and data you can make use of clone function available with SQL server.
Reply With Quote
  #3 (permalink)  
Old 07-03-2007
Junior Member
 
Join Date: Jul 2007
Location: india
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
ms_plz is on a distinguished road
Re: copy the Table Structure

create table tablename 1 from select * from tablename2
Reply With Quote
  #4 (permalink)  
Old 08-04-2007
Junior Member
 
Join Date: Aug 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
sundharmail is on a distinguished road
Re: copy the Table Structure

Using INTO we can copy..

SELECT TOP 0 * INTO New_Table_Name From Old_Table_Name

The Above query will come only the structure for the table..

If U want to copy with the data then remove the "Top 0 "..

SELECT * INTO New_Table_Name FROM Old_Table_Name
Reply With Quote
Reply

  Geeks Talk > Databases > SQL Server


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Query to find structure of a table Geek_Guest SQL 12 09-01-2008 11:12 PM
Creating a table by copying another table's structure Allan Paul Oracle 12 07-12-2007 07:53 AM
How a java table be brought to data table? dhandhan QTP 0 04-15-2007 06:14 AM
Silent Copy - copy your files with the convenience! JobHelper Geeks Lounge 0 04-05-2007 04:40 AM
Deep copy janelyn ASP.NET 1 08-03-2006 02:18 PM


All times are GMT -4. The time now is 01:34 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved