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. |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-24 : 23:26:51
|
hi,u mean like that:CREATE PROCEDURE [dbo].[sp_tst] ASdelete id,name,mail,stDate from tblTablewhere datediff(dd, stDate, getdate()) > 3if 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.
|
 |
|
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. |
 |
|
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 |
 |
|
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
|
 |
|
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. |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-28 : 23:50:03
|
hiIt 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.
|
 |
|
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. |
 |
|
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.
|
 |
|
|