How to: Create and Manage Queries for Searching
You can create and manage your queries to search for work items in your Team Foundation Server using Microsoft Test Manager. You can create the following types of queries:
Default query: Returns a flat list of work items
Direct links query: Returns work items and any work items that are linked to these items
Tree query: Returns a multi-tiered set of work items
These types of queries can also be created using Microsoft Visual Studio 2010. For more information about these types of queries, see Finding Bugs, Tasks, and Other Work Items.
There are two categories of queries.
Team Queries These queries are available to everyone in your team project. Team Queries can only be created and modified by people who have been granted permission to create them by your team project administrator.
My Queries These queries are available only to you.
To create and manage queries using Microsoft Test Manager, use the following procedures:
Create a subfolder to store a query
Create a query
Edit a query
Rename a query
Delete a query
Create a Subfolder to Store a Query
To create a subfolder to store a query
Open Microsoft Test Manager.
Note
To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.
To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.
In the center group menu bar, click Track and then click Queries.
The Queries activity is displayed.
To create a subfolder, right-click Team Queries folder, My Queries folder, or any other folder and then click New folder.
Type the name for this new subfolder.
To add a query to this new subfolder, right-click this new subfolder and then select the type of query that you want to create.
Create a Query
To create a query
Open Microsoft Test Manager.
Note
To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.
To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.
In the center group menu bar, click Track and then click Queries.
The Queries activity is displayed.
To select the folder where you want to create the query, click the folder in the queries folder hierarchy.
To create a query, click the drop-down arrow next to Query, and point to the type of query that you want to create.
To enter a name for this query, type the name.
Important
The first clause shown for the query makes sure that only items from your team project are returned in the results of the query. Do not change this clause.
You can now add the clauses that you require for this query. For more information about how to specify the criteria for your query, see Specify Query Filter Criteria.
(Optional) To change the columns or the sort order for the query results, click Column options.
In the Column Options dialog box, select the columns to add from Available columns, and then click the arrow to add these columns to the Selected columns.
Click Sorting and select the columns that you want to sort by.
Click OK.
(Optional) To group the query results by a column, drag a column header in the query results table to the title bar of the query results.
When the query you created returns the work items that you want to view, click Save on the toolbar.
The query is now saved.
Edit a Query
To edit a query
Open Microsoft Test Manager.
Note
To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.
To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.
In the center group menu bar, click Track and then click Queries.
The Queries activity is displayed.
To display the clauses for a query, click the query in the tree view in Queries.
To update the query, edit the existing clauses or add new clauses.
To see the results of your query, click Run to run the query.
(Optional) To change the columns or the sort order for the query results, click Column options.
In the Column Options dialog box, select the columns to add from Available columns, and then click the arrow to add these columns to the Selected columns.
Click Sorting and select the columns that you want to sort by.
Click OK.
When the query you created returns the correct items that you want to view, click Save on the toolbar.
The query is now updated.
Rename a Query
To rename a query
Open Microsoft Test Manager.
Note
To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.
To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.
In the center group menu bar, click Track and then click Queries.
The Queries activity is displayed.
To rename a query, right-click the query in the tree view in Queries and then click Rename.
Type the new name for this query.
The query is now displayed with the new name in the tree view of queries.
Delete a Query
To delete a query
Open Microsoft Test Manager.
Note
To display the Microsoft Test Manager window, click Start, and then click All Programs. Point to Microsoft Visual Studio 2010 and then click Microsoft Test Manager 2010.
To open the Queries activity, click the down-arrow on the center group switcher and click Testing Center.
In the center group menu bar, click Track and then click Queries.
The Queries activity is displayed.
To delete a query, right-click the query in the tree view in Queries and then click Delete.
A confirmation dialog box is displayed.
To confirm deletion of the query, click Delete query.
The query is no longer displayed in the tree view of queries.