SQL error from AX when using an nvarchar(2000) and LIKE predicate with wildcard in AX2012

I don’t know if this is only with 2012, but we are using AX2012 6.0 CU3 and have found this problem.

  1. Create a new EDT called say “String2000” with StringSize of 2000

  2. Create a new table in AX called say “Table1”

  3. Add a field called say “Field1” to store a string, then change it’s EDT to be the “String2000”

  4. Create a new job with the following code:

Table1 td;




while select * from td where td.Field1 like ‘Kat*’




I found that you get the following error:

"Cannot select a record in Table1(Table1).

The SQL database has issued an error."

If you change the EDT to be string size of 1999 then it works fine. Does anyone know why AX can’t seem to do this with a size above that? Is there a work-around / fix we can use?