Delete records every 30 mins ...

Hi Experts,

Is there a way to schedule a task to delete some records every 15-30 minutes in sqlserver.




Trevor
LVL 1
trevsoftAsked:
Who is Participating?
 
Kishan ZunjareConnect With a Mentor Sr. Software EngineerCommented:
You just need to schedule (e.g. using SQL Agent) some SQL to delete "stale" records, and schedule that to run as often as you need (every minute if you need it to delete promptly after 30 minutes.

DELETE ColName
FROM MyTable AS ColName
WHERE MyCreateDateColumn <= DATEADD(Minute, -30, GetDate())

Hope this will work.
0
 
sammySeltzerCommented:
If you are using sql server 2005 and above and it seems to be the case with you, then you can shedule your script or stored proc to delete every 15 minutes.

Just follow this link:

http://msdn.microsoft.com/en-us/library/ms191439.aspx

0
 
Anthony PerkinsCommented:
>>Is there a way to schedule a task to delete some records every 15-30 minutes in sqlserver.<<
It depends.  If you are using SQL Server Express than you will have to use Windows Scheduled Tasks, other wise you can use SQL Server Agent.

0
 
Alpesh PatelAssistant ConsultantCommented:
Yes, Create a SQL Query and schedule it as SQL Job. It will execute in specified interval and purge data as per your condition in delete query.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.