Strategy to archive data and delete

  • Hello,

    I am using SQL 2012 SE. I have 2 databases say A and B with same structure and relationships. There are 65 tables in each database. A is already replicating data to database C for 35 tables. Now I need to move data from A to B which is greater than getdate()-1 everyday for all the tables and once the move is done I need to delete this data from A. And the same thing the next day and everyday. Since this is for 65 tables its challenging to identify the insert order. Once the insert order is identified the delete order will be the reverse of it.

    Is there a tool or any SP that could help me generate the insert order script? The generate scripts data only is generating the entire data and these databases are almost 400GB. Some tables have 200Mil+ rows.So it takes forever.

    Need your valuable inputs.

    Thanks

    “If your actions inspire others to dream more, learn more, do more and become more, you are a leader.” -- John Quincy Adams

  • What do you mean, 'relationships'? Are there only FK or some triggers do exist?

    If DB has only FK dependencies between tables then sure we can retrieve them from sys.foreign_keys. Next step is to find out circles in dependencies. If no circles found them it's quite possible to order tables by their level in the dependency tree.

    So what is the problem exactly, triggers or something?

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply