Outlook: Using a SQL Filter on the Task List

How can I filter my task list to show only items that meet any of three category values—either A or B or no category at all? I assume a way might exist to use the SQL filter tab, but I can't figure out how.

The fact that you mentioned the SQL tab on the Filter dialog box tells me that you're using Outlook 2002, which added the ability to write more complex queries to filter Outlook folders. Because the SQL syntax used for Outlook filters is the same DAV Searching and Locating (DASL) syntax used for Exchange 2000 Server, a good resource is the Exchange software development kit (SDK) from the Microsoft Development Network (MSDN).

Unfortunately, this Outlook feature doesn't provide much documentation. The best way to learn how to use the SQL tab to customize view filters is to experiment. Choose View, Current View, Customize Current View, Filter. First, go to the More Choices tab in the Filter dialog box, and under Categories, type


Go to the SQL tab to see what the SQL syntax would be:

("DAV:isfolder" = false AND "DAV:ishidden" = false)
 AND ("urn:schemas-microsoft-com:
 office:office#Keywords" = 'A')

Because the SQL tab duplicates the filter you set on the More Choices tab, you now know that the correct DASL schema name for the Categories property is urn:schemas-microsoft-com:office:office#Keywords. After you know that, the SQL syntax is easier to read and modify.

Let's experiment a little more. On the Advanced tab, under Field, choose Categories and set the condition to Is Empty. The SQL tab should now show

("DAV:isfolder" = false AND "DAV:ishidden" = false)
 AND (("urn:schemas-microsoft-com:
 office:office#Keywords" = 'A' AND "urn:
 schemas-microsoft-com:office:office#Keywords" IS NULL))

The last operator is AND, not OR, because you've added a second condition to the original Category = A. But now you have enough information to write your own SQL filter. On the SQL tab, select the Edit these criteria directly. All other tabs will be unavailable check box. Add an expression for the Category = B case and change the AND to OR, as Figure 2 shows:

("DAV:isfolder" = false AND "DAV:ishidden" = false)
 AND (("urn:schemas-microsoft-com:
 office:office#Keywords" = 'A') OR ("urn:schemas-microsoft-com:
 office:office#Keywords" = 'B') OR ("urn:schemas-microsoft-com:
 office:office#Keywords" IS NULL))

You can copy and paste in the SQL box with the Ctrl+C and Ctrl+V shortcuts, respectively. Leave the ("DAV:isfolder" = false AND "DAV:ishidden" = false) expression in place to ensure that the query encompasses only visible Outlook items, which is all that a view can display.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.