?
Solved

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

Posted on 2014-03-31
5
Medium Priority
?
162 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

801 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