473,388 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Copy &Inserting the dataStructure from one table to other table?

3
Hi
I want the structure of the one table should copy to new table.
Can i do this one in our sql server?

please tell me the solution.


thanks in advance and will appreciated.
Jan 17 '10 #1
3 2500
Delerna
1,134 Expert 1GB
What version of SQL server are you using, the procedure for a method will vary, depending on the version.
Within any version there are several methods. Here are a couple that I use in SQL server 2000.
1) DTS Import/Export method copies the table structure and data
In Enterprise manager
....navigate to the database where you want the table to go
....Right click on Tables and select AllTasks/ImportData
....On the "Choose a data source" window
........choose the server and provide login details
........select the database having the source table and click next
....On the "Choose a destination" window it is probably already set
........click next
...I am sure you will be able to figure out the rest.
.
.
2) Using sql which will copy the table structure only
In Enterprise manager
...navigate to the table you want to copy
...right click on the table and copy it
...select menu Tools/query analyser
...In query analyser top section...right click and paste
...You will see something like the code posted below
...You will of course need to change the table name (sysusers in my code) if the source and destination databases are the same
...In the toolbar of query analyser you will see a database dropdown
...Change it to the destination database and click the play button
...Goto the tables of the destination database in enterprise manager
...The table is there. (You may need to refresh the table display)
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE [sysusers] (
  2.     [uid] [smallint] NOT NULL ,
  3.     [status] [smallint] NOT NULL ,
  4.     [name] [sysname] NOT NULL ,
  5.     [sid] [varbinary] (85) NULL ,
  6.     [roles] [varbinary] (2048) NOT NULL ,
  7.     [createdate] [datetime] NOT NULL ,
  8.     [updatedate] [datetime] NOT NULL ,
  9.     [altuid] [smallint] NOT NULL ,
  10.     [password] [varbinary] (256) NULL 
  11. ) ON [PRIMARY]
  12. GO
  13.  

There are other methods and the SQL method in SQL2007 is very different to how I described.
I have done it but I will let someone else more familiar with 2007 than I am describe it..if indeed you have that version
Jan 18 '10 #2
ck9663
2,878 Expert 2GB
Do you need the table structure/metadata or you want to create a table that exactly mimics another table?

~~ CK
Jan 20 '10 #3
nbiswas
149 100+
Apart from the answer given by Mr. Delerna, I would like to add a few more

Assuming 2005+ , you can use SSIS(Export /Import wizard tool)

Assuming 2008+, you can take the advantage of

Generate Scripts

Another option is Select ..Into and Insert into Select. Look into this article

SQL SERVER – Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE

Hope this helps
Mar 24 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Liming | last post by:
hello, I have the follwoing code <div id="detailtable" style="visibility:hidden"> <table id="detailtablehidden" width="100%" border="0"> .... </table> </div>
6
by: Fan Ruo Xin | last post by:
I try to copy a table from production system (DB2 UDB EEE V7.2 + fixpak5) to the testing system (DB2 UDB V8.1 + fixpak4a). I moved the data from productions system by using the following steps:...
2
by: charles-brewster | last post by:
I'm trying to write a simple JavaScript function which will use a button to copy table cell data into a form input text box as the "value" attribute. The following is intended to test the...
0
by: Kushwaha | last post by:
Hi, Any buddy help me to inserting multiple rows, Editing them, or deleting them in a any type of grid. I don't want to use any type of text box, combo box.
1
by: prabhun2004 | last post by:
hi all i use postgresql database. There are two databases in that namely 'db1','db2'. In 'db1', thers is a table named as 'table_common'. In 'db2', there is a table named as...
1
by: Tomek | last post by:
Hi, I'm new in C# programming. I received an order to create application with ODBC technology. Application seems to be simple, It should copy table from database, for example SQL server, to...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
4
by: remya1000 | last post by:
i'm using VB.NET i have 4 computers in network. when i press a button i need to delete a table from computer 2,3,4 and i need to copy that table from computer 1 to 2,3,4. and this file is a...
3
by: wasimgh | last post by:
this isi my first question here and I hpe I find the solution, that I need the SQL code of copy table to new one woth primary key, for example I have table of barcode, quantity, descryption,.......
1
by: ayyanki | last post by:
Hello all, I'm still learning about c# and I have a major function that I need to write (in a forms application), and I have no idea how to go about it. Here's the scenario: I have a text file...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.