Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete a row after a certain amount of time? 2

Status
Not open for further replies.

OnAFan

Technical User
Mar 13, 2002
120
US
Hello, I am not all that familiar with developing stored procedures so please bear with me...
I am building an asp app that allows a single user to create temporary accounts via the app (this will populate a user table). These temp accounts should expire/be deleted after 24 hours. Is this possible? If so, could someone point me in the right direction for developing this procedure? Thanks in advance,
Terry Wright
 
TerryWright,

Add a datetime or timestamp column to the table which will contain the timestamp when the record is added.

Any stored procedure can then simply test the records timestamp to the current date/time for it's age. If older than allowed, simply delete.

For example . . .

delete
from table
where datediff(hh, tmsColumn, getdate()) > 24

Look up the datediff function in T-Sql or any SQL help source for info on the parameters.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top