There are quite a few threads in the Service Desk forum on this subject but they're tailored to SD data. In fact, Support will soon be posting a tool to remove incidents. If you're talking about Service Desk processes then you should look in the SD forum.
I gathered various scripts that I have and wrapped them in a stored procedure that will either 'close' a process or completely remove it altogether. By close, I mean 1) deleting persistence data so timeouts and escalations will not run 2) updating tasks to show that they're completed 3) updating status on the process reporting data 4) entering a comment to show what happened.
Here are two example of how to use this procedure. This first deletes and the second completely removes.
-
EXEC
dbo.CloseProcess @ReportProcessID = N'WF01', @Status = 'Closed', @Comment = 'Closing this process because...', @ClosedBy = '
user@yourcompany.com'
- EXEC dbo.CloseProcess @ReportProcessID = N'WF01', @DeleteInsteadOfClose = 1
*backup your data first!