CAML: Select SharePoint List Items with not empty column values

Once I needed a CAML query for selecting elements with non-empty column. I wanted to select all the users with name detected (filled) and with OS "Windows".

First I decided to use <Neq> construction and <Value Type='Text'></Value>. I thought it’s an analog for var != "". But the result was wrong.


So I watched CAML documentation and found <IsNotNull> construction. It appeared to be right:


This query returns list items where "OS" is "Windows" and UserName not null.

If you need to select elements with Null-values, you should use <IsNull> construction. Notes of web-specialist
Since 2009