Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS etl tables backup concept


SSIS etl tables backup concept

Author
Message
Golden_eye
Golden_eye
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 228
Hello,

I have a production database which is loaded regularly via SSIS packages.
In the database there are etl (schema) tables which are loaded by every load with all the info, so that they can be used as a backup at some point.

Now I want to have the full history of the etl tables only on my local server (which is a copy of the production) and to keep only the last three months on production.
Do you have an idea how to create this SSIS?

Thanks.
Terry Troisi
Terry Troisi
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 143
I'm not sure I'm fully understanding what you're attempting, but are there any datetime columns in your data you can use to extract out three months?
aaron.reese
aaron.reese
Mr or Mrs. 500
Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)

Group: General Forum Members
Points: 589 Visits: 898
When you say three months, do you mean a rolling 93 days, or archive a month at the end of each month (i.e. have between 3 and 4 months on the PROD server).

Why do you only want recent data on the PROD server. If it is a performance issue then you should be looking at server configuration and indexing. If it is space or security then you should be looking at partitioning the database and limiting access to the older partitions.
Golden_eye
Golden_eye
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 228
Hello Veteran,

Thank you for the reply.

First it is a space issue and also design issue.

However what I need is to keep only the data from the last ~90 days.
aaron.reese
aaron.reese
Mr or Mrs. 500
Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)Mr or Mrs. 500 (589 reputation)

Group: General Forum Members
Points: 589 Visits: 898
So what we are looking at is a rolling delete process

My preference (for codeability) would be a sproc in the database that takes two arguments Tablename to be deleted and Days to Keep

The sproc would build a dynamic SQL statement to remove the records

NOTE the code below has not been checked, it is symantec rather than syntactic.


CREATE PROCEDURE dbo.uspDeleteOldData (@TableName nvarchar(50), @DaysToKeep int default = 90)
AS

DECLARE @SQL as nvarchar(max)

SET @SQL = N'DELETE FROM ' + @TableName + ' WHERE CreateDate <= ''' + cast(DateAdd(days,(@DaysToKeep * -1), getdate()) as nvarchar)

sp_executeSQL @SQL




I would then build an SSIS package that simply has a list of SQL tasks that calls the sproc for each table you need to clean up.

NOTE that you may end up with lots of sparsely populated index pages so you will need to clean up the database on a regular basis to remove the unused space.
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8310 Visits: 19457
NOTE the code below has not been checked, it is symantec rather than syntactic.


I think you meant 'semantic', unless your solution is proposing an unorthodox anti-virus methodology :-)


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search