遇到难题,RecordSet 和存储过程 的问题,请各位高手帮忙,急,急在线等

请各位大虾帮忙看看,如何解决这样的问题:
由于记录多,为了减少迪卡尔乘积,使用如下方法
在存储过程中建立临时表,再使用关联:

两个创建临时表的语句
select z1 into 临时表1 from t1 where 条件1
select z1 into 临时表2 from t1 where 条件2

一个与临时表关联的总语句,(最终需要的查询结果)
select t1.id,(select top1 z1 from 临时表1 where 关联 ) as writer,
(select z1 from 临时表2 where 关联) as check
from t1 where 条件

,如何才能使第三个select 语句的结果返回到RecordSet中,
我使用set Rs = cmd.execute(proc)
if not Rs.eof then ... 时,提示Rs对象关闭不能操作,
别的存储过程也是这样的语句就成功的阿,

不知道说清楚没有??
---------------------------------------------------------------

SET NOCOUNT ON
select z1 into #临时表1 from t1 where 条件1
select z1 into #临时表2 from t1 where 条件2

select t1.id,(select top1 z1 from 临时表1 where 关联 ) as writer,
(select z1 from 临时表2 where 关联) as check
from t1 where 条件
SET NOCOUNT OFF

---------------------------------------------------------------

存储过程开始处加:

set nocount on

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus