Error when using a CTE in SSIS
<p>I am using an ADO.net source in SSIS and running a query containing a CTE. I am getting the following error: </p>

<blockquote>
  <p>NO COLUMN INFORMATION WAS RETURNED BY THE SQL COMMAND</p>
</blockquote>

<p>I used <code>SET NOCOUNT</code> and <code>set fmtonly off</code>, but still no luck.</p>

<p>Can you please help me with resolving this issue?</p>

<p>sample query:</p>

<pre><code>with MyCTE as
(
select 
Pno,
jdo,
er,
dtsent,
dtapproved,

ROW_NUMBER() OVER(Partition by Pno,jdo,er ORDER BY dtapproved )  as rn,
Dense_Rank() OVER(ORDER BY Pno,jdo,er )  as rnk  from(
select v1.*,v2.max_jdo as jdo from 
table1 v1 
left join(select Pno,max(jdo) as max_jdo,er from 
 table2
Group by Pno,er ) v2 on
v1.Pno=v2.Pno and
v1.er =v2.er)T
)

select  
c1.Pno ,
c1.jdo, 
c1.er,
case when c1.dtapproved  is null then c1.dtsent else NVL(c2.dtapproved,c1.dtsent) end as Datesent,
c1.dtapproved,
from  MyCTE c1
Left join MyCTE c2
on c1.rn = c2.rn + 1 and c1.rnk=c2.rnk
</code></pre>