|
| 1 | +-- This is a script to delete a given DataCollection (by dataCollectionId) and |
| 2 | +-- all associated rows in other tables. |
| 3 | +-- Change the value of @dcId to the dataCollectionId you would like to delete. |
| 4 | +-- Disclaimer: |
| 5 | +-- This script is not extensively tested. It also currently will leave behind |
| 6 | +-- some orphaned rows. |
| 7 | +-- Run this at your own risk and beware of cascading deletes. |
| 8 | + |
| 9 | +SET @dcId := 1000; |
| 10 | + |
| 11 | +DELETE |
| 12 | +FROM ImageQualityIndicators |
| 13 | +WHERE dataCollectionId = @dcId; |
| 14 | + |
| 15 | +DELETE ProcessingJobParameter |
| 16 | +FROM ProcessingJobParameter |
| 17 | + JOIN ProcessingJob |
| 18 | +WHERE ProcessingJob.processingJobId = ProcessingJobParameter.processingJobId AND |
| 19 | + ProcessingJob.dataCollectionId = @dcId; |
| 20 | + |
| 21 | +DELETE ProcessingJobImageSweep |
| 22 | +FROM ProcessingJobImageSweep |
| 23 | + JOIN ProcessingJob |
| 24 | +WHERE ProcessingJob.processingJobId = ProcessingJobImageSweep.processingJobId AND |
| 25 | + ProcessingJob.dataCollectionId = @dcId; |
| 26 | + |
| 27 | +DELETE AutoProcProgramMessage |
| 28 | +FROM AutoProcProgramMessage |
| 29 | + JOIN ProcessingJob |
| 30 | + JOIN AutoProcProgram |
| 31 | +WHERE ProcessingJob.processingJobId = AutoProcProgram.processingJobId AND |
| 32 | + AutoProcProgramMessage.autoProcProgramId = AutoProcProgram.autoProcProgramId AND |
| 33 | + ProcessingJob.dataCollectionId = @dcId; |
| 34 | + |
| 35 | +DELETE AutoProcProgram |
| 36 | +FROM AutoProcProgram |
| 37 | + JOIN ProcessingJob |
| 38 | +WHERE ProcessingJob.processingJobId = AutoProcProgram.processingJobId AND |
| 39 | + ProcessingJob.dataCollectionId = @dcId; |
| 40 | + |
| 41 | +DELETE |
| 42 | +FROM ProcessingJob |
| 43 | +WHERE dataCollectionId = @dcId; |
| 44 | + |
| 45 | +DELETE AutoProcProgramMessage |
| 46 | +FROM AutoProcProgramMessage |
| 47 | + JOIN AutoProcProgram |
| 48 | + JOIN AutoProcIntegration |
| 49 | +WHERE AutoProcIntegration.autoProcProgramId = AutoProcProgram.autoProcProgramId AND |
| 50 | + AutoProcProgramMessage.autoProcProgramId = AutoProcProgram.autoProcProgramId AND |
| 51 | + AutoProcIntegration.dataCollectionId = @dcId; |
| 52 | + |
| 53 | +DELETE AutoProcProgram |
| 54 | +FROM AutoProcProgram |
| 55 | + JOIN AutoProcIntegration |
| 56 | +WHERE AutoProcIntegration.autoProcProgramId = AutoProcProgram.autoProcProgramId AND |
| 57 | + AutoProcIntegration.dataCollectionId = @dcId; |
| 58 | + |
| 59 | +DELETE |
| 60 | +FROM AutoProcIntegration |
| 61 | +WHERE dataCollectionId = @dcId; |
| 62 | + |
| 63 | +DELETE |
| 64 | +FROM GridInfo |
| 65 | +WHERE dataCollectionId = @dcId; |
| 66 | + |
| 67 | +DELETE |
| 68 | +FROM DataCollection |
| 69 | +WHERE dataCollectionId = @dcId; |
0 commit comments