RE: Archive data

RE: Archive data

 

  

Elena,
Sorry, I don't have the time to write this up completely for you, but I could give you some examples. It would be an INSERT into your archive table FROM your current table with a very long WHERE function expression that would compare the date of the first day of the month for each record to a date thirteen months ago. Then you would need a DELETE from your data table with the same WHERE clause.

declare @DateThirteenMonthsAgo datetime
set @DateThirteenMonthsAgo = dateadd(month, -13, GETDATE())

Your derived comparison date would be convert(datetime, yearmo + '01', 112)

Hope this helps. This is a tall order for a beginner.
DD


-----Original Message-----
From: Elena Frenkel [mailto:elena.[Email address protected]
Sent: Tuesday, February 22, 2005 2:43 PM
To: [Email address protected]
Subject: RE: Archive data


**A LazyDBA.com subscriber has responded to your lazydba.com post**
**LazyDBA.com mail shield has forwarded you this email,
**and removed any attachments, and kept your email address secret
**from this person, and any viruses/trojans.
**If you reply to this email, the person will see your email address as normal
**Anything below this line is the original email text



Hi Diane,
Thank you.
Can you give me an example? I'm not an advance developer. I'm only the
beginner. Thank you. Elena.

-----Original Message-----
From: Davis Diane (DOC-CEN)
[mailto:mssqldba-ezmlmshield-x855349.[Email address protected]
Sent: Tuesday, February 22, 2005 2:36 PM
To: LazyDBA Discussion
Subject: RE: Archive data

You could build a datetime variable using CONVERT, SUBSTRING, and
concatenation that makes the first day of each month. Then you could compare
that to GETDATE() minus 13 months.

Diane Davis


-----Original Message-----
From: Elena Frenkel
[mailto:mssqldba-ezmlmshield-x76248908.[Email address protected]
Sent: Tuesday, February 22, 2005 2:29 PM
To: LazyDBA Discussion
Subject: Archive data


Hi all,
I need archiving data from the tables older than 13 months.
I don't have datetime column in my tables. The only column I have shows
month and year and looks like '200501' has 'char 6'.
How I can retrieve data older than 13 months?

Thank you.






MS Sql Server LazyDBA home page