Solved

Delete records every 30 mins ...

Posted on 2011-09-09
4
222 Views
Last Modified: 2012-05-12
Hi Experts,

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




Trevor
0
Comment
Question by:trevsoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 36515093
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36516555
>>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
 
LVL 7

Accepted Solution

by:
Kishan Zunjare earned 500 total points
ID: 36522156
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
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 36522492
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

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question