Using Not Equals (<>) in SQL Statements

Using Not Equals (<>) in SQL Statements

The following provides information about how to write a query that contains a not equals (<>) operation. The following code example uses <> in the where clause, and the XML parser interprets it as a malformed XML tag.

INSERT INTO TEST (str,num) values ('philip', 3);
<ns0:SQLExecute xmlns:ns0=
     <ns0:StatementText>select * from viewmyreport_auditforecast 
          where column1 <> true;</ns0:StatementText>

If you use the <> characters in your SQL statement, you get an illegal character error. There are two ways around this error:

  1. Replace the special XML characters < and > with the HTML named entity characters: &lt; and &gt;.

    Certain combinations of characters cause the XML parser to think that it is an XML escape sequence. For example, a > alone does not cause a problem.

  2. Enclose the complete SQL statement with the XML escape CDATA, as in the following code example:

    <ns0:SQLExecute xmlns:ns0=
          select * from viewmyreport_auditforecast where column1 <> true;

Community Additions

© 2016 Microsoft