<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan Vice&#039;s Blog &#187; Tracking</title>
	<atom:link href="http://www.ryanvice.net/category/wf3-5/tracking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryanvice.net</link>
	<description>Implementation notes and development techniques</description>
	<lastBuildDate>Thu, 11 Feb 2010 13:43:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQL Query to Get Tracking Data in Workflow Foundation 3.5</title>
		<link>http://www.ryanvice.net/wf3-5/sql-query-to-get-tracking-data-in-workflow-foundation-3-5/</link>
		<comments>http://www.ryanvice.net/wf3-5/sql-query-to-get-tracking-data-in-workflow-foundation-3-5/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 14:12:09 +0000</pubDate>
		<dc:creator>Ryan Vice</dc:creator>
				<category><![CDATA[Tracking]]></category>
		<category><![CDATA[WF 3.5]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.ryanvice.net/?p=176</guid>
		<description><![CDATA[Below is a query that will return tracking data when using the SQL

Simply substitue the GUID for the WF instance that you want to find out tracking details about and then fire the query to see the tracking data.

declare  @WorkflowInstanceInternalId   bigint

select   @WorkflowInstanceInternalId = WorkflowInstanceInternalId
from dbo.WorkflowInstance
where
         WorkflowInstanceId = [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a query that will return tracking data when using the SQL</p>
<p><span id="more-176"></span></p>
<p>Simply substitue the GUID for the WF instance that you want to find out tracking details about and then fire the query to see the tracking data.</p>
<pre>
<pre class="brush: sql;">declare  @WorkflowInstanceInternalId   bigint

select   @WorkflowInstanceInternalId = WorkflowInstanceInternalId
from dbo.WorkflowInstance
where
         WorkflowInstanceId = 'E3573C8D-96D7-47C9-AE64-CB3E197A18CE'

select   wie.EventDateTime,
         'Workflow ' + twe.Description [Status],
         wie.EventOrder,
         '' [QualifiedName],
         '' [TypeName],
         '' [UserDataKey],
         '' [UserData_str]
from dbo.WorkflowInstanceEvent wie
   inner join dbo.TrackingWorkflowEvent twe
      on (wie.TrackingWorkflowEventId = twe.TrackingWorkflowEventId)
where wie.WorkflowInstanceInternalId = @WorkflowInstanceInternalId
union
select   se.EventDateTime,
         aes.Description [Status],
         se.EventOrder,
         ai.QualifiedName,
         case when charindex('.',reverse(t.TypeFullName)) &gt; 1
                   then right(t.TypeFullName,charindex('.',reverse(t.TypeFullName))-1)
                   else ''
            end [Type],
         '' [UserDataKey],
         '' [UserData_str]
from dbo.ActivityExecutionStatusEvent se
   inner join dbo.ActivityExecutionStatus aes
      on (se.ExecutionStatusId = aes.ExecutionStatusId)
   inner join dbo.ActivityInstance ai
      on (se.ActivityInstanceId = ai.ActivityInstanceId)
   inner join dbo.WorkflowInstance wi
      on (ai.WorkflowInstanceInternalId = wi.WorkflowInstanceInternalId)
   left join dbo.Activity a
      on (a.WorkflowTypeId = wi.WorkflowTypeId
      and ai.QualifiedName = a.QualifiedName)
   inner join dbo.Type t
      on (a.ActivityTypeId = t.TypeId)
where se.WorkflowInstanceInternalId = @WorkflowInstanceInternalId
union
select   ue.EventDateTime,
         'UserData' [Status],
         ue.EventOrder,
         ai.QualifiedName,
         '' [TypeName],
         ISNULL(ue.UserDataKey, '') [UserDataKey],
         ue.UserData_str
from dbo.vw_UserEvent ue
   inner join dbo.ActivityInstance ai
      on (ue.ActivityInstanceId = ai.ActivityInstanceId)
where ue.WorkflowInstanceInternalId = @WorkflowInstanceInternalId
order by EventOrder,
         EventDateTime</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanvice.net/wf3-5/sql-query-to-get-tracking-data-in-workflow-foundation-3-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
