U02012033 SQLServerException previewing SQL variable

Document ID : KB000084466
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
Error Message :
U02012033 Query could not be executed: 'com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part identifier 'a.AH_Client' could not be bound. (Client: '0022', PREVIEW, Variable: 'INC00214003.SEC_SQL.WITH_PARA.VARA')'

Using an alias in SEC_SQL Variable objects causes the above error.

The SQL statement causes the error when the preview button is clicked:

 
select a.AH_OType,
a.AH_Idnr,
o.OH_Idnr,
a.AH_TimeStamp1
from AH a
inner join OH o on a.AH_OH_Idnr = o.OH_Idnr
where a.AH_Client = 22
and o.OH_Name ='<Object_Name>'

While the statement above is correct the driver throws an error, the statement below does work:
 
select AH.AH_OType,
AH.AH_Idnr,
AH.AH_OH_Idnr,
AH.AH_TimeStamp1
from AH
inner join OH on AH.AH_OH_Idnr = OH.OH_Idnr
where AH.AH_Client = 22
and OH.OH_Name ='<Object_Name>'
Cause:
Cause type:
Other
Root Cause: Since the SEC_SQL statements are being processed through Microsoft's JDBC driver you may see this type of issue with older JDBC versions.
Resolution:
Update your system to use the latest Microsoft (MS) SQL JDBC driver.

For additional information about Microsoft products, including the SQL JDBC drivers, contact Microsoft.

Fix Status: No Fix

Additional Information:
Workaround :
Do not use an alias in SQL statement.