Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Disable SQL query optimizer tool that removes trailing blanks

When working with the length function used in a WHERE or ORDER BY clause, disable the DB2 SQL query optimizer from removing trailing blanks by changing the variable length optimization settings.

Why does the length function used in a WHERE or ORDER BY clause remove the trailing blanks from a VARCHAR column but does not remove them in a SELECT column?

Is this a bug?

No, this is done by design to provide the DB2 query optimizer more flexibility when picking the fastest implementation for your SQL query request. If you want to disable this query optimizer technique, you can create a QAQQINI options file and set the VARIABLE_LENGTH_OPTIMIZATION attribute to *NO.

Dig Deeper on DB2 UDB (universal databases)

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.