SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Copy tables from one server to another


Copy tables from one server to another

Author
Message
adonetok
adonetok
SSChasing Mays
SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)

Group: General Forum Members
Points: 643 Visits: 789
Company is doing server and application update.
I need to copy about 100 tables from server A to server B.
Since the project is under test mode and I need to do the same copy job once week.
Can some expert tell me which way is the best way to do it?
Now, I use "Import data..." to do it but every time need to select a lot of tables.
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16331 Visits: 19073
With the import/export data wizard, you have the option to save the SSIS package for later use. That way, you can use it as it is or do any modifications needed without creating all again and again.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Todd Carrier
Todd Carrier
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1907 Visits: 936
Sounds like maybe a good job for Snapshot Replication...
http://technet.microsoft.com/en-us/library/ms151832.aspx

Todd Carrier
MCITP - Database Administrator (SQL 2008)
MCSE: Data Platform (SQL 2012)
benjamin.reyes
benjamin.reyes
Mr or Mrs. 500
Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)

Group: General Forum Members
Points: 525 Visits: 2286
Snapshot replication is great for this, but is there a reason why you couldn't just automate a restore of the database backups. That way you can also verify the backups you are currently making are good.
adonetok
adonetok
SSChasing Mays
SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)

Group: General Forum Members
Points: 643 Visits: 789
Because I only need to import all tables which my applications will need.(user tables)
Someone else will do the rest.
Backup will backup all objects.
adonetok
adonetok
SSChasing Mays
SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)SSChasing Mays (643 reputation)

Group: General Forum Members
Points: 643 Visits: 789
I created SSIS and ran it.
It copied all tables I need but missing all index from source server.
How to copy exactly the same index for all tables as in source server?
There is no any option to set it up.
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16331 Visits: 19073
You could create the scripts for the tables with the option to script indexes (and probably other dependent objects).
You can use the script in a Execute SQL Task at the beginning of the package ensuring that you have the validation to drop existing objects.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
benjamin.reyes
benjamin.reyes
Mr or Mrs. 500
Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)Mr or Mrs. 500 (525 reputation)

Group: General Forum Members
Points: 525 Visits: 2286
So far you have a couple options.

Snapshot Replication
Restore backup
Script out the objects
Export Data Teir Application
smitty-1088185
smitty-1088185
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 599
You could also use filegroup backups. Move all the user tables to a separate filegroup and back up and restore just the tables you need.
Keep in mind any foreign keys
sql-lover
sql-lover
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1575 Visits: 1930
adonetok (1/17/2014)
Company is doing server and application update.
I need to copy about 100 tables from server A to server B.
Since the project is under test mode and I need to do the same copy job once week.
Can some expert tell me which way is the best way to do it?
Now, I use "Import data..." to do it but every time need to select a lot of tables.


I've done this hundreds of times with SSIS. You can also use BCP, but SSIS is probably easier. If both table's schemas are the same, you should be ok. You can create the Indexes after, which I do recommend, so your insertion process will be also faster.

Important! Set identity insert on on SSIS so you can preserve original IDs, in case you have one on each table.

You can compare both sets, after you finish, with following T-SQL query. Just adjust and change names accordingly:


--Compare both sets. It should return no rows.
SELECT n.ID AS [DeletedID], o.ID AS [InsertedID]
FROM dbo.Copy n
FULL OUTER JOIN dbo.Source o
ON (n.ID = o.ID)
WHERE o.ID IS NULL OR n.ID IS NULL



If source and target are the same, it will return no rows. Otherwise, above query will show you what was deleted and what was inserted.

Last but not least, be sure to run SSIS or copy from one table to other during off peak hours or a maintenance window. If not, you will generate some locks on the source table and you will take the chance or not getting both tables totally sync'ed.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search