469,148 Members | 1,567 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,148 developers. It's quick & easy.

Date Stored Procedure

Hi all,

I am trying to write a stored procedure that will delete records in a
table that are older then 30 days. I am checking against a field that
is called PositionDate. Can someone point me in the right direction?

TIA
Jul 20 '05 #1
4 2493
DELETE
FROM Sometable
WHERE positiondate < DATEADD(D,-30,CURRENT_TIMESTAMP)

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #2
Thanks that works great. My next newbie question is, is there a way to
have the SQL server run this automatically once a day?

On Mon, 8 Dec 2003 21:04:46 -0000, "David Portas"
<RE****************************@acm.org> wrote:
DELETE
FROM Sometable
WHERE positiondate < DATEADD(D,-30,CURRENT_TIMESTAMP)

--
David Portas
------------
Please reply only to the newsgroup


Jul 20 '05 #3
Yes, you can create and schedule a job:

http://msdn.microsoft.com/library/en...omate_42r7.asp

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #4
Thanks for the link. It was very helpful!

On Mon, 8 Dec 2003 22:17:00 -0000, "David Portas"
<RE****************************@acm.org> wrote:
Yes, you can create and schedule a job:

http://msdn.microsoft.com/library/en...omate_42r7.asp

--
David Portas
------------
Please reply only to the newsgroup


Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Marc Pelletier | last post: by
8 posts views Thread by JIM.H. | last post: by
8 posts views Thread by John Wildes | last post: by
5 posts views Thread by Řyvind Isaksen | last post: by
2 posts views Thread by Brad Pears | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.