O'Reilly logo

Professional Team Foundation Server by Mickey Gousset, Erik Gunvaldson, Jean-Luc David

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.5. Using Work Item Query Language

As mentioned earlier, work items have their own query language, called the Work Item Query Language (WIQL). This language is a SQL-like construct that, when used in conjunction with the work item tracking object model, can be used to build powerful queries that retrieve detailed information from the work item tracking system.

This section will give you a brief primer on the Work Item Query Language. For all the details, you should check out the documentation provided in the Visual Studio SDK. For this brief primer, you will learn about the different aspects of a WIQL query, and then see a short application that uses a WIQL query.

Every WIQL query consists of a SELECT statement, containing the fields to retrieve, and a WHERE statement to help determine what information to retrieve. So a sample query to retrieve all the work item ids assigned to Developer1 might look like this:

System.ID from workitems where System.AssignedTo = 'Developer1'

You always must specify the fields you are interested in. When specifying fields, you can use either the friendly name or the reference name. In the above example, we have used the reference name. Best practices dictate that you use reference names at all times, as these will never change, while friendly names may change at some point in the future. You can select any field type in a query, except for plain text fields. And all your standard operators, such as =, >, and <, work in the WHERE clause section. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required