user2450064 user2450064 - 2 months ago 10
SQL Question

How to query a field with ASCII 13 or "Carriage return"?

I Imported an XML file into a table.Then I tried to query the field that are not null. I have a field which seems to be blank or null but still returned in the query.

I'm not sure if this is newline but upon searching the net it is what they called "Carriage return"

the part of the imported XML looks like this:


I tried to query it it's not pulled in the ff:

Where Myfield <> null

Where Myfield <> ""

I tried to select it using ASC() function and it returns 13 but when trying to filter it by this code below, I am getting "Invalid Procedure Call" error

SELECT * FROM Table1 where asc(Myfield) = '13'


Perhaps what you're seeing is actually CRLF, a carriage return (ASCII 13) plus linefeed (ASCII 10), which is actually 2 characters. It should be easy to check ...

SELECT * FROM Table1 WHERE Myfield = Chr(13) & Chr(10)

Just in case the imported XML brought in any spaces or other non-printing characters, you could check for CRLF anywhere in the field.

SELECT * FROM Table1 WHERE Myfield ALike '%' & Chr(13) & Chr(10) '%'

ALike differs from Like in that it signals the db engine to expect ANSI wild cards, % and _, instead of Access' * and ?