473,396 Members | 2,026 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,396 software developers and data experts.

How to copy a table (with the data) from one server to another?

mikek12004
200 100+
How to copy a table (with the data) from one server to another (the two servers are in different PCs)? Basically if I could move the data to a txt file inthe form of the insert command (like the import/export of phpmyadmin) all would be ok
Dec 3 '08 #1
16 22978
ck9663
2,878 Expert 2GB
Do you want to transfer the table in SQL Server A to SQL Server B as a table? Or you want to export the content of a table from SQL Server A to another PC?

-- CK
Dec 3 '08 #2
mikek12004
200 100+
Tables from SQL sever A to SQL server B which is in different host (those two are not related in any way) (For the table sructure I script the table as "Create into" take the query and run it in the other SQL -with the appropriate modifications -is anything similar for the table data?)
Dec 4 '08 #3
ck9663
2,878 Expert 2GB
You can use your management studio and use the Import wizard or connect to the other SQL server through linked server and do a SELECT * INTO...

-- CK
Dec 4 '08 #4
pattr
1
you can use the sql import export wizard for copying the table structure with data.but am not sure if u are copying more than table,the relationship will exists in the new table or not.
Dec 29 '08 #5
choose destination database -->right click-->tasks-->import Data-->choose source databse ,then following the wizard choose the source table,ok?
Jan 7 '09 #6
mikek12004
200 100+
A little different problem, how can you copy a table (with its data) from one database to another when BOTH DATABASES ARE ON THE SAME SQL server? Tried the
Expand|Select|Wrap|Line Numbers
  1. SELECT * INTO NewTable FROM existingdb.dbo.existingtable;
but then when I checked the resulting generated scripts from the 2 tables saw that the declaration of a column as primary key was gone () any suggestions?
Jan 20 '09 #7
ck9663
2,878 Expert 2GB
Kindly make a separate post for this one so that others can view and learn from this.

Thanks,

-- CK
Jan 20 '09 #8
mikek12004
200 100+
Didn't get it, make a different post you mean start a new thread? For this case I guess the title of this post includes this question also. In any case here are a bit more details, I have a databese with some tables which get regulary updated I want these tables to be able to 'copy' them in a 'backup' database make some other arrangments to the original database and then 'post' them back. As mention above the 'SELECT INTO' command makes all my primary keys disappear, so for the tables structure I will take the create scripts generated by SQL for the tables I want and then I will populate them with an 'insert' into my problem is that before all that I want to be able to check if a table exists in the backup database and if it does to make a 'drop' so the following 'create table' command would not cause an error saw somewhere something like 'if exists' but couldn't make it to work. Again any ideas would be helpful
Jan 21 '09 #9
ck9663
2,878 Expert 2GB
SELECT INTO creates a new table. Since it's a new table, all relationship, constraints, etc will not be automatically created. This looks like a production data. What you could do is to backup the entire database twice. One is your actual backup that you can keep/archive. The other is for you to do your "other arrangements". You have to put your production database offline first so no one can change it. After you're done with your "arrangements" drop your production database and use your "arranged" database as your new production.

To check if the table is existing, trythis function.

Good luck.

-- CK
Jan 21 '09 #10
mikek12004
200 100+
The problem is that from the one databese I want 1 table (say 2 columns one primary key with autoincrement) to copy it with its data to another database tried the "insert into DB.table1 select * from DB.table2" but throws error when trying to write in the primary key column also tried the export wizard still the same. Any ideas?
Jan 30 '09 #11
ck9663
2,878 Expert 2GB
What's the error?

-- CK
Jan 30 '09 #12
@ck9663
Dear can you tell me, i have a problem when i export any database from server a to server b then tables are export but there primary key and Auttoincrement and bind valuse not moved. you have to again set it

tell me what to i do to export table with these valuse.

regards
vikas
Apr 22 '09 #13
mikek12004
200 100+
Personally I wanted to move 15 tables form database A to B in SQL 2008 so I used the "insert to" command and then for all restriction (primary keys, etc) which are in seperate folder on the right tree-view panel. right-click script as->add restriction (or something like that) and the SQL will automatically generate the code for each restriction, executed that code in the new database and vouala! you're done
Apr 23 '09 #14
i am using sql 2005. in this i open data base A then onthe table i right click and then chosse script-->create to-->new query editer
then i database B then i open his New query editer and past that script but it show error near '(' but i dont thing so there is some erro

tell me what to i do.
Apr 23 '09 #15
mikek12004
200 100+
Try the import/export wizard, this will get you the data for sure if the restrictions re not copied you will have to do it manually with each table as said above,
to copy table/data use
Expand|Select|Wrap|Line Numbers
  1. SELECT * INTO test.dbo.Table_1 FROM source.dbo.Table_1;
  2.  
and for the restriction the SQL will produce something like
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE test.dbo.Table_1 ADD CONSTRAINT PK_Table_1 PRIMARY KEY (id)
Apr 24 '09 #16
To copy data from one table to another where the tables are located in different databases (regardless of their type or location), you can use a tool called Data Moving Tool. It does exactly what you need.
Nov 28 '10 #17

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

Similar topics

6
by: Kenneth Osenbroch | last post by:
Hi. I want to create a trigger that only allows delete from table A if corresponding record in table B does not exist. Any idea on how this can be done? Thanks, Kenneth.
3
by: Raj | last post by:
Hi, I am trying to add some more information to the table which already has a lot a data (like 2-3000 records). The new information may be adding 2-3 new columns worth. Now my questions are:...
1
by: Mo | last post by:
Hi, I have two datasets on two databases one remote and one local. I am trying to copy the local data into the remote. Both tables have the same structure. I use the following DataTable...
6
by: Bill | last post by:
Hi All, New to the whole .Net and C# thing but trying. In classic asp this was simple to fill a table with dynamic content and hyperlinks. Here is an example of what I am trying to do in classic...
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...
11
by: BeckR | last post by:
Hello - Thanks for reading my post. I am a newbie when it comes to VBA programming, but have managed to do what I need to do, until now. I have an Access 2000 database (running WinXP Pro...
1
by: JimDavie | last post by:
Okay guys, I'm struggling with understanding how to properly update a table with values from a temp table I created from an APPEND query which provides totals information off of an applicaion...
2
by: toofunny24 | last post by:
I have two tables and both have identical fields for the most part. Both tables are linked by product id. One table is used for entering actual data. Table two contains the specs/target numbers...
1
by: jerome london | last post by:
I am working on a project for a class and would like to know if or how to get my data base to auto up date a table with informatiion from another table. Oh I am working with Visual Studio 2010, Any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.