Requirement is to Move Data Older than 3 years from Production DB to Archive DB , and Once Moved Delete those records from Production DB , so at any point of time Production DB will have only last three years of records.
i want to achieve this by SSIS , i read quite a few articles about Data Archival but couldn't figure out the best Approch.
I am New to SSIS
i want to achieve exactly something like this (answer given in Below link)with extra condition saying move only those records which are older than 3 years and then delete those records.
https://dba.stackexchange.com/questions/25867/moving-data-from-one-db-to-another-using-ssis
Criteria for an accepted answer answer should address
- scalability
- complexity
- failure handling
- reliability
Have you considered table partitioning instead? You can move the old records to a totally different disk and still leave them available in the same table. It can also help with performance in some cases... all without an SSIS package.
Create 2 OLE DB Connection Managers. Name them Production and Archive and have them point to the correct servers and database. These CMs are what SSIS uses to push and pull data from the databases.
Add a Data Flow Task. A DFT is the executable that will allow row by row manipulation of the data. Double click on the Data Flow Task. Once inside, add an OLE DB Source and and OLE DB Destination to the canvas. The OLE DB Source is where the data will come from while the OLE DB Destination provides the insert power.
The logic you would want to implement is a Delete first approach, much as I outlined in the other answer.
This query will delete all the rows older than 3 years and push them into the dataflow. In your OLE DB Source, make the following configuration changes
Archive
toProduction
Connect the OLE DB Source to the OLE DB Destination. Double click on the OLE DB Destination and configure it
Archive
If you do not need to span an instance, the above logic can be condensed into a single
Execute SQL Task
Also note with this approach that if you have identity columns you will need to provide an explicit column list and turn on and off the IDENTITY_INSERT property.
You can use the OUTPUT clause to delete and return the data to be moved in one go.
The code can also be accessed on SQLFiddle
Now I will show you the exact steps you need to follow in SSIS to reproduce the example:
Hope it helps.
Other things to keep in mind, because you are deleting and moving data around, transactional consistency is very important. Imagine half way through your delete/move, the server went down, you then end up with data being deleted but not made it to the archive.
If you are unsure about how to protect your data by enforcing transactional consistency, please seek help from other SQL/SSIS experts on how to use transactions in SSIS.