• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Mindy Curnutt and Associates

  • Services
  • About
  • Blog
Home » Automatically Deleting a Job

April 29, 2016 By Mindy Curnutt

Automatically Deleting a Job

On a project my team was working on recently, we wanted to run a stored procedure every 10 minutes for 2 days to collect data over time. At the end of the 2 days, we would FTP the results up to a folder and remove any evidence that we had been on the server (clean up the tables we’d been writing to, drop the stored procedure, and in turn, drop the very job we had created to run this whole contraption.

How to delete the very job that is running?  (eyebrows raised). Is this even possible? At first we thought not. I mean, wouldn’t that tear a hole in the space-time continuum?  I asked my team to look a little deeper, there had to be a way. Maybe we could go through xp_cmdshell and call a statement that would essentially be in another process and that could do it? Let’s get creative.

Then they found it.

Automatically Delete a Job

Wow. 20 years of SQL Server and I never noticed that before. (Base of Palm to Forehead).

Thanks to Eric Blinn & Mayil Chandran for researching this and making me aware.

Mindy Curnutt

Mindy Curnutt is a five time Microsoft Data Platform MVP with over 20 years of experience working with Database Solutions. She specializes in Performance Tuning and Architecture. She speaks regularly across North America at Local User Groups, SQL Saturdays and Conferences.

Filed Under: What I Learned Today Tagged With: SQL Agent, sql server, SSMS

Reader Interactions

Primary Sidebar

Categories

  • Awards
  • Azure
  • MDS
  • Power BI
  • Powershell
  • Spatial Data
  • SQL
  • What I Learned Today

Archives

  • December 2018
  • November 2018
  • September 2018
  • June 2018
  • May 2017
  • April 2017
  • December 2016
  • November 2016
  • September 2016
  • May 2016
  • April 2016

Recent Comments

  • Twitter Campaign/Brand Management In Power BI – Curated SQL on Power BI, Twitter and the Old Settlers Music Festival

Recent Posts

  • Live! 360 Speaker
  • BOOK PUBLICATION: SQL Server 2017 Administration Inside Out
  • Power BI Class on October 11 – 2018
  • My Article at IT Pro Today – Azure Cosmos DB vs. SQL Server
  • Restoring a SQL Backup from Azure Blob Storage

Footer

Resources Pages

Volunteer Activity
Books and Presentations
Spatial Data Resources
Learning Resources
Speaking Engagements

Privacy Policy

Site Map

Join My Newsletter

Subscribe to my mailing list

* indicates required



Copyright Mindy Curnutt© 2021