Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Posts
    8

    Unanswered: Deleting records that get too old

    I must admit I dont know all that much about SQL, which is why I hope someone can show me the light. I have a script almost finished, however I have no idea how to have it trim database entries that are older than, say, 90 days. Any ideas?

  2. #2
    Join Date
    Apr 2004
    Location
    Kansas City, MO
    Posts
    734
    WHERE date_file > DATEADD(dd,90,GETDATE())
    MeanOldDBA
    derrickleggett@hotmail.com
    When life gives you a lemon, fire the DBA.

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    "Stay away from the light!" [Donkey from "Shrek"]
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by rdjabarov
    "Stay away from the light!" [Donkey from "Shrek"]

    Hey, I thought it was my job to handle the disconnected ramblings.....


    And btw, you do have a row added datetime column, right?

    Of course you do.

    (hey buddy, wanna buy a watch...cheap)
    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.

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Disconneted ramblings...

    ...Brett's job. Not yours.

    ...or rdjabarovs...

    ...<insert random Maragarita reference here>...

    [sniped!]

    ...or connect the ramblings with a join, but not in WHERE clause.

    WHERE disconnected_ramblings = ....

    Not good.

    Is it Friday yet?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Apr 2004
    Location
    Kansas City, MO
    Posts
    734
    I'm confused.

    Huh?

    I think I lost my =
    MeanOldDBA
    derrickleggett@hotmail.com
    When life gives you a lemon, fire the DBA.

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Kansas?

    There are only 2 things that come from Kansas boy......

    Steers....ok never mind

    BUT, can you tell me the movie?

    Did we scare him/her off....

    And what about DB2

    Damn...gotta run to THE city...

    later
    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.

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Brett, someday some company will create a programming language that will allow you code in stream-of-consciousness, and you will be a happy man.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  9. #9
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Quote Originally Posted by derrickleggett
    WHERE date_file > DATEADD(dd,90,GETDATE())
    Wait a minute, shouldn't it be "WHERE date_file < DATEADD(dd,-90,GETDATE())"?
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  10. #10
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Now WHERE did I put that backup...?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  11. #11
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by blindman
    Brett, someday some company will create a programming language that will allow you code in stream-of-consciousness, and you will be a happy man.

    They did...it's called REXX

    I love the INTERPRET keyword most of all scarecrow....
    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.

Posting Permissions

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