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.
DELETE
DF
OUTPUT
DELETED.*
FROM
dbo.DeleteFirst AS DF
WHERE
DF.RecordDate > dateadd(y, 3, current_timestamp);
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
- change the Connection Manager from
Archive
to Production
- change the query type from "Table or View" to "Query"
- paste your query and click the Columns tab to double check the query parsed
Connect the OLE DB Source to the OLE DB Destination. Double click on the OLE DB Destination and configure it
- Verify the Connection Manager is the
Archive
- Ensure the Access Mode is "Table or View - Fastload" (name approximate)
- You might need to check the Retain IDs based on your table design - if you have identity column, then do check it if you want ID 10 from the production system to be ID 10 in the Archive system
- Select the actual table
- On the Mapping tab, ensure that all the columns mapped. It does this automatically by matching names so there shouldn't be a problem.
If you do not need to span an instance, the above logic can be condensed into a single Execute SQL Task
DELETE
DF
OUTPUT
DELETED.*
INTO
ArchiveDatabase.dbo.DeleteFirst
FROM
dbo.DeleteFirst AS DF
WHERE
DF.RecordDate > dateadd(y, 3, current_timestamp);
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.