I have the following SQL to be queried. It is a valid SQL. Unfortunately, it is too long for a string in VBA. Anyone knows of a workaround to run this query?
SQL = "SELECT A.cust_ky, A.incid_id, A.OPEN_TS, A.CLOSE_TS, A.REC_UPD_TS, B.wrkgp_id, A.CURR_AGNT_KY, A.incid_ttl_dn " _
& "FROM (MAINTBLS.INCID_FAB A INNER JOIN MAINTBLS.DEPTMNT B ON A.curr_wrkgp_ky=B.wrkgp_ky) " _
& "WHERE B.wrkgp_id='" & wrkgp & "' And (A.open_fg = 1 OR A.pend_fg = 1)" _
& "ORDER BY A.cust_ky, A.curr_agnt_ky ASC"
rs.Open SQL, con, adOpenKeyset
SQL
string is not actually being truncated, it just apears to be because the Value field of the watch window is limited to 255 characters. To verify your string addDebug.Print SQL
to your code and view the result in theImmediate
window. FWIW try adding anASC
to each field in theORDER BY
clause - ieORDER BY A.cust_ky ASC, A.curr_agnt_ky ASC
" OR A.pend_fg = 1)" _ & "ORDER BY A.cust_ky, A.curr_agnt_ky ASC"
, if this is a cut and paste of your SQL, it will not run in VBA.