Solved

Delete records every 30 mins ...

Posted on 2011-09-09
4
221 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 28

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

740 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