• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Create views using SQL/DAVX filters

Slipstick Systems

› Outlook › Rules, Filters & Views › Create views using SQL/DAVX filters

Last reviewed on August 14, 2018     7 Comments

One of Outlook's little known gems is the SQL filter in the Views Filter dialog. Although it looks confusing and technical, it's surprisingly easy to use. In many cases, you can let Outlook create a query for you by creating your criteria on the other tabs then enable SQL filtering and edit the query as needed. While you can create power filters if you know some SQL syntax, you don't need to know a lot about SQL to create filters not possible using the other filter tabs.

If you use the filter dialog often, you've already discovered the filters use the AND operator to string different criteria together. For example, you can create filters to view messages "From Amy AND Received in the last 7 days ", but not filters for messages "From Amy OR Received in the last 7 days". The filter dialog doesn't support the NOT operator directly, although you can use the Advanced filter to create some NOT filters indirectly. Using the SQL filter, you can easily create OR and NOT filters.

When you create the filter "From Amy AND Received in the last 7 days", the SQL looks like this:

("urn:schemas:httpmail:fromname" LIKE '%Amy%' AND %last7days("urn:schemas:httpmail:datereceived")%)

Switch to the SQL tab and change the AND to OR, so the rule shows all e-mail from Amy OR all e-mail that was received in the last 7 days.

("urn:schemas:httpmail:fromname" LIKE '%Amy%' OR %last7days("urn:schemas:httpmail:datereceived")%)

You can also use the NOT operator to restrict views. This filter shows all messages not from Amy that were received before yesterday.

NOT ("urn:schemas:httpmail:fromname" LIKE '%Amy%' OR NOT "urn:schemas:httpmail:datereceived" <= 'yesterday')

More Information

See Using Query Builder another option to use AND / OR operators in the filter dialog.

Create views using SQL/DAVX filters was last modified: August 14th, 2018 by Diane Poremsky

Related Posts:

  • How to configure Outlook to sync only recent messages when you have a
    Using a Large Exchange Mailbox on a Small Drive
  • Using Query Builder
  • Calendar list view
    Create a view for appointments that don't have reminders
  • Using Search Folders

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
7 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Matt
September 12, 2025 8:24 am

Can you get this view to appear on the Search Folders display?

0
0
Reply
Diane Poremsky
Author
Reply to  Matt
September 12, 2025 12:29 pm

Search folders don't have a SQL tab so it can't be used in the search... but it does work in the view for a search folder.

If you want to use SQL to create the search criteria, you can use VBA and redemption. (I need to write that up.)

0
0
Reply
James
August 12, 2024 10:36 am

Would be helpful to know how to get the SQL tab to display if it's not there. I had it before, on another work laptop, and I remember having to configure that. Now, I have to find it again, and no one seems to be saying how to get it there but assuming it is there. Still looking...

0
0
Reply
Diane Poremsky
Reply to  James
August 12, 2024 10:55 am

The SQL tab is there if it is supported but not all filter dialogs support it. You should have it on Views but not with conditional formatting.

2024-08-12_10-44-16
2024-08-12_10-43-49
0
0
Reply
Daniel
August 13, 2018 5:44 pm

Am I right in understanding there's just no way to get this to show on the Advanced Find dialogue?

0
0
Reply
Diane Poremsky
Author
Reply to  Daniel
August 13, 2018 11:56 pm

Correct. It's not available on all filter dialogs and there is not a registry key to add it. You can add the query builder, which gives control over AMD/OR operations.
https://www.slipstick.com/outlook/using-query-builder/

1
0
Reply
Daniel
Reply to  Diane Poremsky
August 15, 2018 12:34 am

Thanks for confirming DIane. I've added the QB already.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 29

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment