Dec 30, 2009

Basic steps for a Sharepoint workflow

I always have problems configuring the basic setup for a Sharepoint workflow, especially creating tasks.

Things to remember:
1. Each task must have its own correlation token.
2. In the event for onWorkflowActivated you should set the workflowID = workflowProperties.workflowID.
3. In the event for createTask, you must set the taskId = Guid.NewGuid()
4. Create a fault handler to log exceptions to the HistoryList and add Microsoft.Office.Server.Diagnostics.PortalLog.LogString("error details")

Dec 10, 2009

How to cut and paste Active Directory group members

The Active Directory Users and Groups MMC plugin (dsa.msc) is quick for finding groups and members, but hard to copy and paste from. Or at least I haven't figured out how yet.

So we go to the command line:
dsquery group -name ServiceDesk|dsget group -members > ServiceDeskMembers.txt

This command will output all the members of the group ServiceDesk to the text file ServiceDeskMembers.txt

Dec 4, 2009

How to find SQL queries with high CPU usage

Using this query in SQL Server 2005, you can see the top 5 queries ranked by CPU usage (

select DB_NAME(QP.dbid) as "Context_Database",top_5.*

from (SELECT TOP 5 query_stats.plan_handle AS "Query_Hash",

SUM(query_stats.total_worker_time)/SUM(query_stats.execution_count)AS "Avg CPU Time",
MIN(query_stats.statement_text)AS "Statement Text"



SUBSTRING(ST.text, (QS.statement_start_offset/2)+ 1,

((CASE statement_end_offset


ELSE QS.statement_end_offset

END - QS.statement_start_offset)/2) + 1)AS statement_text

FROM sys.dm_exec_query_stats AS QS

cross apply sys.dm_exec_sql_text(QS.sql_handle)as ST

) as query_stats

GROUP BY query_stats.plan_handle

ORDER BY 2 DESC) as top_5
cross apply sys.dm_exec_query_plan(top_5.Query_Hash) as QP