Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2006
    Posts
    3

    Unanswered: sql archive script

    hi,
    I need a script to deletes records from my DB older than 30 days.
    is their anywhere a script that can help me ?
    how should i write ?
    using some quesy tool ?
    thanks
    idan

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    do you stamp each record with the date it was entered?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Oct 2006
    Posts
    3

    reply

    yes I have a timestamp for each record
    thanks
    idan

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    is it the date created or the date last modified?

    what is the data type of the column?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Please post some ddl. Are the datetime columns named the same across all of the tables? But, I question why you need to do this

    DELETE is such an ugly word

    Archive is much nicer...how about move stale data to mirrored archive tables
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  6. #6
    Join Date
    Oct 2006
    Posts
    3

    reply

    hi,
    the data is no longer relevent for me. these are logs events for some system.
    the timestamp column is date type.
    what i wrote today was something like :
    delete * from table
    where TIMESTAMP > 'getutcdate()-60'
    is that the best way to do that ?
    can I run these command as a cycled job occuring every day using windows ,machnism ?
    thanks
    idan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •