SQL Data Maintenance Sample
This sample demonstrates partitioning of tracking data in the tracking database. When partitioning is enabled, a new set of tables is created periodically for tracking data, so that old data can be archived and dropped from the main database without affecting currently running applications. Tracking data is still created in the original tables with partitioning enabled, but it is then moved to the partitioned tables when the workflow completes.
In the sample application, a SqlTrackingService object is instantiated and added to the runtime as with the other samples in this section. In this case, however, the PartitionOnCompletion setting of the tracking service is set to True, and the database's partition interval is set to "d". This tells the database to horizontally partition the data daily, so that a new set of tracking tables is created each day. (Other valid values are "m" for monthly, and "y" for yearly. The default setting is to partition data monthly.)
Next, a workflow is instantiated and executed, and the resulting tracking data schema is printed to the console by using helper functions in the DataAccess class. When the program executes, the console shows the partitioned data tables that are created. New tables are created every day that the sample is run.
To build the sample
Download the sample by clicking Download Sample.
This extracts the sample project to your local hard disk.
Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.
Go to the source directory of the sample.
At the command prompt, type MSBUILD <Solution file name>.
To run the sample
In the SDK Command Prompt window, run the .exe file in the SqlDataMaintenance\bin\debug folder (or the SqlDataMaintenance\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.
Creating the Tracking Database
The SQL services that are installed by Windows Workflow Foundation use Microsoft SQL Server to store information. You can use Microsoft SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE) for these tasks.
Windows Workflow Foundation Setup does not install the databases that are required by these services; however, Setup installs the SQL scripts for creating and configuring the databases for these services.
To create the SQL tracking database
Using Microsoft SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE), create a new database named Tracking by using the SQL query statement:
CREATE DATABASE Tracking
Note: When using both the SqlTrackingService and the SqlWorkflowPersistenceService in a workflow application, it is recommended to use a single database for both persistence and tracking.
In the SQL Query Analyzer workspace, select the database that you created in step 1 in the list of available databases.
On the File menu, click Open and open the SQL script %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<language>\Tracking_Schema.sql.
Execute the query by clicking Execute or by pressing F5 to create the SQL Tracking Service tables.
On the File menu, click Open and open the SQL script %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<language>\Tracking_Logic.sql.
Execute the query by clicking Execute or by pressing F5 to create the SQL Tracking Service stored procedures.
Other ResourcesTracking Samples
Simple Tracking Sample
Query Using SQLTrackingService Sample
Tracking Using User Track Points Sample
EventArgs Tracking Sample
Query Using SQLTrackingService Sample
File Tracking Service and Query Sample
Using the Tracking Profile Object Model Sample
Using the SqlTrackingService Service
Data Maintenance with SqlTrackingService
© 2007 Microsoft Corporation. All rights reserved.