Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delete records every 30 mins ...

Posted on 2011-09-09
4
Medium Priority
?
231 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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