PDA

Click to See Complete Forum and Search --> : GUN TO HEAD, HELP ME NOW PLEASE :)


JasonGS
Aug 14th, 2000, 05:44 PM
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!

BruceG
Aug 14th, 2000, 07:32 PM
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