Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Regarding job ?

Author  Topic 

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-24 : 23:04:44
hi,

How to create a job schedule to delete data from table automatically after 3days(starting from date added).
Can i get any idea?

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-24 : 23:10:12
Does table have date_add column? If so, you can use datediff(dd, date_add, getdate()) > 3 in where clause.
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-24 : 23:26:51

hi,
u mean like that:
CREATE PROCEDURE [dbo].[sp_tst] AS
delete id,name,mail,stDate from tblTable
where datediff(dd, stDate, getdate()) > 3

if so, i can't create it.
And what's the command to use in step1.
plz can u tell me more detail? coz i've never created any job previously.
Thanks.

quote:
Originally posted by rmiao

Does table have date_add column? If so, you can use datediff(dd, date_add, getdate()) > 3 in where clause.

Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-24 : 23:35:25
You can create job undet tasks in em, just run delete statement in job step. Find how to create job in books online.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-04-25 : 12:27:42
First tell does your table have Datetime column?


Like this:

Delete from yourtable where datediff(day,datecolumn,getdate())>=3
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-28 : 02:15:15
hi,
i want to test first.
how to test to delete after 10mins?
then, do i need to create schedule?

thanks.

quote:
Originally posted by sodeep

First tell does your table have Datetime column?


Like this:

Delete from yourtable where datediff(day,datecolumn,getdate())>=3

Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-28 : 22:41:38
Try datediff(min, stDate, getdate()) > 10, you can create a sql job without schedule and run the job manually.
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-04-28 : 23:50:03
hi
It doesn't work if i don't start and refresh that job.
Why?

quote:
Originally posted by rmiao

Try datediff(min, stDate, getdate()) > 10, you can create a sql job without schedule and run the job manually.

Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-30 : 22:55:30
What do you mean? Sql job will not run by itself if don't set schedule.
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-05-01 : 22:16:36

thanks.
i don't know about job at all previously.
plz let me know is it right if i set schedule like every 4days 5a.m to delete over 3days records.

quote:
Originally posted by rmiao

What do you mean? Sql job will not run by itself if don't set schedule.

Go to Top of Page
   

- Advertisement -