Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQl Server - background task to delete records.

Posted on 2016-10-28
8
Medium Priority
?
63 Views
Last Modified: 2016-10-28
Is there a way to create some Task in SQL server that deletes records from a table based on a date column in said table?
0
Comment
Question by:HLRosenberger
[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
8 Comments
 
LVL 30

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 500 total points
ID: 41864192
You can create a SQL job and inside that you can do that with your DELETE command.  Yes you can use a date in there.

Or if it is a one time activity , create a script and inside that delete the required rows.
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 1000 total points
ID: 41864205
Yes.  
In SSMS, go to SQL Server Agent -> Jobs, right-click and select "New Job..." and fill out the relevant fields.  Your SQL will go under "Steps" and you can schedule the job to run when you want under "Schedules".
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41864269
it's not a one time thing.  I want it to  be done daily.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 1

Assisted Solution

by:Jeff Edmunds
Jeff Edmunds earned 500 total points
ID: 41864287
You can combine what the last two folks said to do... Your SQL Agent Job can be scheduled to run daily and the job itself can be to execute the script which deletes the records. When you create the SQL job, add a new Step, and select Transact SQL Script as the Type. In the Command box, just type in the SQL script to use. Then under Schedules you can set the job to run daily at whatever time you wish.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 41864372
"I want it to  be done daily."
That's not a problem.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41864556
paulmacd - Do I have to add a step to the job?  Does the job call a stored proc that has my SQL Delete?  Or can I define the SQL delete right in the main job?
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41864586
ah, I got the job working.   Now just to schedule it to run every day.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41864587
Thanks to all!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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…

730 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