Results 1 to 2 of 2

Thread: GUN TO HEAD, HELP ME NOW PLEASE :)

  1. #1

    Thread Starter
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    Does anyone know how I can use a SQL statement to delete records older than say 1 hour?

    I've got 1000 records all stamped with a Date and 24/h Time in the "lastupdate" field of this database on MS SQL server.

    What I am wanting to do is delete any record older than 1 hour... does anyone know how I can do this without creating a recordset and checking each row?

    Prompt response would be greatly apprecieated!

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Don't do it! Let's talk this thru now ...

    The SQL statement should look something like this:

    DELETE FROM MyTable
    WHERE DATEDIFF (hh, lastupdate, GETDATE()) > 1
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

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



Click Here to Expand Forum to Full Width