473,412 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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 2571
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
7
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r =...
8
by: JIM.H. | last post by:
Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate=”” gives error in asp.net, how should I do...
8
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as...
5
by: yvind Isaksen | last post by:
I have a page with an optional integer-field, and one asp:calendar control. I use a stored procedure to save the data in SQL Server. When all fields contains data, the code works great! But if the...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
1
by: gderosa | last post by:
Hey everyone...I need to create a job which occurs once monthly that is based on a stored procedure that contains as a rough example: CREATE PROCEDURE CompareDate @CurrentDate datetime AS ...
2
by: Brad Pears | last post by:
I am working on a vb.net 2005 project using sql server 2000 as the backend . I am having a bit of problems with date variables... Here is the scenario... I have a table that includes a couple...
4
by: oracle newbie | last post by:
create or replace PROCEDURE LIBHOME(ldt zen.logdatetime%TYPE) IS lv_count NUMBER; BEGIN SELECT COUNT(*) INTO lv_count FROM zen WHERE TRUNC(logdatetime) = TRUNC(sysdate); IF...
4
Soniad
by: Soniad | last post by:
Hello, I am passing date and time individually to stored procedure as parameters as follows : Exec mySP '01/31/2009' , '5:03:56 PM' whithin this stored procedure, i have declared one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.