--you get instanceid from this query

DECLARE @InstID bigint  = (select top 1 InstanceID from tbWorkFlowTemplateInstance with (nolock)
							where EntityID in (123)
							order by StartDate desc)

DECLARE  @Entityid bigint = 123
--2386524

SELECT	* 
FROM	tbWorkflowpendingtasks
WHERE	InstanceID = @InstID
AND		EntityID = @Entityid

--begin tran
--delete from tbWorkflowpendingtasks
--where InstanceID in (2386525)
--and EntityID = 271
----commit tran
----rollback tran


SELECT	wft.Description
,		* 
FROM	tbWorkFlowTasksStatus wfts with (nolock)
JOIN	tbWorkFlowTasks wft on wfts.TaskID = wft.TaskID
WHERE	InstanceID = @InstID



--begin tran
--delete from tbWorkFlowTasksStatus
--where InstanceID in (2386525)
----commit tran
----rollback tran


SELECT	* 
FROM	tbWorkFlowTemplateInstance
WHERE	InstanceID = @InstID and Entityid = @EntityID


--begin tran
--delete from tbWorkFlowTemplateInstance
--where InstanceID in (2386525)
--and EntityID = 123
----commit tran
----rollback tran