Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SSIS etl tables backup concept Expand / Collapse
Author
Message
Posted Saturday, September 7, 2013 2:56 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, September 25, 2014 8:39 AM
Points: 27, Visits: 220
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.
Post #1492486
Posted Thursday, September 12, 2013 2:26 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 3, 2014 12:32 PM
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?
Post #1494363
Posted Monday, September 16, 2013 3:45 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 10:34 AM
Points: 386, Visits: 624
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.
Post #1495310
Posted Wednesday, September 18, 2013 2:29 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, September 25, 2014 8:39 AM
Points: 27, Visits: 220
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.
Post #1495805
Posted Wednesday, September 18, 2013 9:19 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 10:34 AM
Points: 386, Visits: 624
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.

Post #1495978
Posted Friday, September 20, 2013 12:10 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:20 AM
Points: 5,180, Visits: 12,033
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1496717
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse