Friday, March 23, 2012

Help with a store procedure

I am trying to create a store procedure that look at a table and only maintain 30 worth of data only forever. The data that fall outside the 30 days need to be deleted. Can anyone help me with this?
Thanks
Lystracreate a time stamp field on your table. Then you can create a sp like...

Create Proc Delete_Old_Junk
As
DELETE FROM TABLE WHERE DATE(dd,timestampfield,Getdate()) > 30|||dateDIFF:

DELETE FROM TABLE WHERE DATEDIFF(dd,timestampfield,Getdate()) > 30

You will need to schedule this procedure as a job that runs once per day.|||Thanks you guy, it did the trick.

Lystra|||just going to fast, spinning too many plates, too much coffee and soda, too many things going on.

but in 99 minutes I splash down on my couch with all of my favorite indulgences.|||...and you totally deserve it. Have a great weekend!

Lystra

No comments:

Post a Comment