Anyone know why I can't Execute the Following SQL in Recordset.DoQuery? Always returns COM Exception. Runs fine in SSMS, also there are no sub queries in the Select line.
Any help is deeply appreciated,
Mike
SELECT ROW_NUMBER() OVER (ORDER BY SJ.JOBID) As [#], SJ.SUBJOBID, SJ.ENTEREDDATE, ST.DESCRIPTION AS [STATUS], SJ.JOBTITLE , JL.QUOTELINETYPE, JL.STOCKCODE, JL.DESCRIPTION, JL.QTY, JL.AVECOST, CASE JL.LINETYPE WHEN 'Q' THEN CASE Z.DIRECTRATE WHEN 'Y' THEN CASE JL.QUOTELINETYPE WHEN 'H' THEN ROUND(ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.FXCOSTAFTERDISCOUNT * ISNULL(COSTFXRATE, 1), Z.SUMDEC) ELSE ROUND(JL.QTY * JL.FXCOSTAFTERDISCOUNT * ISNULL(COSTFXRATE, 1), Z.SUMDEC) END ELSE CASE JL.QUOTELINETYPE WHEN 'H' THEN ROUND((ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.FXCOSTAFTERDISCOUNT) / ISNULL(COSTFXRATE, 1), Z.SUMDEC) ELSE ROUND((JL.QTY * JL.FXCOSTAFTERDISCOUNT) / ISNULL(COSTFXRATE, 1), Z.SUMDEC) END END ELSE ROUND(JL.QTY * JL.AVECOST, Z.SUMDEC) END AS [TOTALCOST], JL.OrigSellPr As [ORIGSELLPR], CASE WHEN JL.LINETYPE = 'Q' AND JL.QUOTELINETYPE = 'H' THEN ROUND(ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.ORIGSELLPR * (1 - (JL.LINEDISCOUNT / 100)),Z.SUMDEC) ELSE ROUND(JL.QTY * JL.ORIGSELLPR * (1 - (JL.LINEDISCOUNT / 100)), Z.SUMDEC) END AS [TOTALSALE], ISNULL(SJ.ACTIVE, 'N') AS ACTIVE, JL.CONTRACTLINESEQNO, JL.U_OM_Contract As [CTC] FROM ENPRISE_JOBCOST_JOBLINES JL LEFT JOIN OADM Z ON Z.PRICEDEC != -999 LEFT JOIN ENPRISE_JOBCOST_SUBJOB SJ ON SJ.SUBJOBID = JL.SUBJOBID LEFT JOIN ENPRISE_JOBCOST_JOB J ON J.JOBID = SJ.JOBID LEFT JOIN ENPRISE_JOBCOST_STATUS ST ON ST.SEQNO = SJ.STATUS Where LINETYPE = 'Q' And J.JOBID = 11900