Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Copy tables from one server to another Expand / Collapse
Author
Message
Posted Friday, January 17, 2014 10:11 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 6:52 AM
Points: 291, Visits: 558
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.
Post #1532166
Posted Friday, January 17, 2014 10:26 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 6:14 PM
Points: 2,763, Visits: 5,908
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.
I am a great believer in luck, and I find the harder I work the more I have of it. Stephen Leacock

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1532172
Posted Friday, January 17, 2014 10:52 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 9:55 AM
Points: 1,298, Visits: 782
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)

Post #1532184
Posted Friday, January 17, 2014 12:06 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 4:52 PM
Points: 235, Visits: 1,174
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.
Post #1532218
Posted Friday, January 17, 2014 12:11 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 6:52 AM
Points: 291, Visits: 558
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.
Post #1532224
Posted Friday, January 17, 2014 1:00 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 6:52 AM
Points: 291, Visits: 558
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.
Post #1532246
Posted Friday, January 17, 2014 1:07 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 6:14 PM
Points: 2,763, Visits: 5,908
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.
I am a great believer in luck, and I find the harder I work the more I have of it. Stephen Leacock

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1532253
Posted Friday, January 17, 2014 1:18 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 4:52 PM
Points: 235, Visits: 1,174
So far you have a couple options.

Snapshot Replication
Restore backup
Script out the objects
Export Data Teir Application
Post #1532261
Posted Monday, January 20, 2014 6:19 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, March 28, 2014 6:45 AM
Points: 48, Visits: 394
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
Post #1532832
Posted Wednesday, January 22, 2014 2:38 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, April 14, 2014 2:24 PM
Points: 302, Visits: 1,067
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.
Post #1533842
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse