Remove Workflow Instance from WorkflowTracking & WorkflowPersistence

To remove from WorkflowTracking:

declare @guid uniqueidentifier
set @guid = 'd37ef09d-fd95-4550-aac7-7d467286f3f3';
declare @id bigint;

set @id =
	(select workflowinstanceinternalid from workflowinstance
	where workflowinstanceid = @guid)

delete from workflowinstance
	where workflowinstanceinternalid = @id

delete from workflowinstanceevent
	where workflowinstanceinternalid = @id

delete from userevent
	where workflowinstanceinternalid = @id

delete from activityinstance
	where workflowinstanceinternalid = @id

delete from activityexecutionstatusevent
	where workflowinstanceinternalid = @id

To remove from WorkflowPersistence:

declare @guid uniqueidentifier
set @guid = 'd37ef09d-fd95-4550-aac7-7d467286f3f3';

DELETE FROM [WorkflowPersistence].[dbo].[InstanceState]
      WHERE uidInstanceID = @guid;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: