?
Solved

moving 80 tables from one db to another server/db but with different where clauses

Posted on 2014-03-31
5
Medium Priority
?
163 Views
Last Modified: 2014-04-10
2 queries as below

SELECT * FROM   PAGORI.RASA.MARKING_TARGET   WHERE  PICK_CODE_DATE IN ('2011-07-31','2012-01-11')
SELECT * FROM   PAGORI.RASA.FUND_SOURCE WHERE PICK_CODE_DATE IN ('2011-07-31','2012-01-11')

--------------------------

SELECT * FROM   PAGORI.RASA.SOURCE   WHERE OFFICE_CODE IN ('3262','4373','4373','4377','8443','9843','4332')  
SELECT * FROM   PAGORI.RASA.PICTOUR  where   OFFICE_CODE IN ('3262','4373','4373','4377','8443','9843','4332')
4 other such table transfers

--------------------------
 
SELECT * FROM   PAGORI.RASA.RESPROT WHERE OFFICE_CODE IN ('3262','4373','4373','4377','8443','9843','4332') AND PICK_CODE_DATE IN ('2011-07-31','2012-01-11')
SELECT * FROM   PAGORI.RASA.SCOREMNT WHERE OFFICE_CODE IN ('3262','4373','4373','4377','8443','9843','4332') AND PICK_CODE_DATE IN ('2011-07-31','2012-01-11')
70 more such table transfers

These 80 table data need to be transfered to another server (same schema on destination database). The 80 tables needs to be truncated and then loaded.

is the attached ssis the best method to do it..?
Untitled.png
0
Comment
Question by:25112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:David Todd
ID: 39967792
Hi,

Depending on what the source database looks like, would it be easier to restore a backup of the current database on the destination server, and then filter off what isn't needed?

HTH
  David
0
 
LVL 5

Author Comment

by:25112
ID: 39968238
there are 500+ tables, David and some ofthem are too big.. so deletes will take lot of log maintenance and time..

i am open to ideas. thanks.
0
 
LVL 5

Author Comment

by:25112
ID: 39968257
SSIS option seems like i have to hard code 80 queries? seems tedious, but benefit is i can save it and rerun as needed.. but if i need to do same concept for another set of 100 tables, that becomes hard again.

any way to automate this better by segments? 2 table transfers have one set of WHERE; 8 have another set of WHERE; and 70+ have another set of WHEREs.
0
 
LVL 35

Accepted Solution

by:
David Todd earned 2000 total points
ID: 39970391
Hi,

This does not look something that can be easily data driven, unless those conditions are the same for each and every table.

If that is the case, create a table that has the tablenames in it, and write a cursor or while to loop through the 80 tables and do them one-by-one with some dynamic code.

And if you need another 100 tables done in the future, then that is realtively easy.

HTH
  David

PS Dropping a table has minimal logging (and locking), and if initially the restored database is in simple mode while dropping the unwanted tables and deleting unwanted rows then the logging shouldn't be too bad. Then change recovery model to full and take a backup.
0
 
LVL 5

Author Comment

by:25112
ID: 39992461
thank you David-
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question