改成一个CREATE TABLE 语句加多个UPDATE、INSERT语句吧!
改好后搞成存储过程最好,不搞成存储过程也行。

解决方案 »

  1.   

    有没有谁能解释一下为什么该SQL语句在SQL Server Query Analyzer中执行只需2秒钟即可完成,而在VB中使用ADO打开却要几分钟的时间(大约两分钟)
      

  2.   

    写一个存储过程吧,这样在客户端调用比较方便。
    在vb中使用ado的话最好不要用select into 语句
      

  3.   

    我觉得问题应该是出在空值上,如果所有连接的左右基本匹配的话就不会那么慢了,我只是不明白这其中的原因所在;这一SQL语句中有很多是动态的(根据查询统计的结果生成),如[s1.SUMCOUNT as '清大堂',s2.SUMCOUNT as '新大堂',s3.SUMCOUNT as '汉厨面点',s4.SUMCOUNT as '汉大堂',s5.SUMCOUNT as '报损',s6.SUMCOUNT as '汉酿部',s7.SUMCOUNT as '新吧台',s8.SUMCOUNT as '红汤料',s9.SUMCOUNT as '新厨部',s10.SUMCOUNT as '清吧台',s11.SUMCOUNT as '汉吧台',s12.SUMCOUNT as '清厨部',s13.SUMCOUNT as '汉厨部',s14.SUMCOUNT as '汉办'];及[,out_s as s2,out_s as s3,out_s as s4,out_s as s5,out_s as s6,out_s as s7,out_s as s8,out_s as s9,out_s as s10,out_s as s11,out_s as s12,out_s as s13,out_s as s14 where P.CPBH is not null and (P.CPBH*=s1.CPBH and s1.DWDM='10') and (P.CPBH*=s2.CPBH and s2.DWDM='11') and (P.CPBH*=s3.CPBH and s3.DWDM='111') and (P.CPBH*=s4.CPBH and s4.DWDM='12') and (P.CPBH*=s5.CPBH and s5.DWDM='144') and (P.CPBH*=s6.CPBH and s6.DWDM='17') and (P.CPBH*=s7.CPBH and s7.DWDM='2') and (P.CPBH*=s8.CPBH and s8.DWDM='20') and (P.CPBH*=s9.CPBH and s9.DWDM='21') and (P.CPBH*=s10.CPBH and s10.DWDM='3') and (P.CPBH*=s11.CPBH and s11.DWDM='4') and (P.CPBH*=s12.CPBH and s12.DWDM='6') and (P.CPBH*=s13.CPBH and s13.DWDM='7') and (P.CPBH*=s14.CPBH and s14.DWDM='9')];我没想过用存储过程是否能实现,就算能实现也不见得有多大优势。没有必要的话我也不会用select into 语句,不过我并不认为在ADO在使用select into 有什么不妥,问题不在于此;remanwang(玩玩儿)能否说明一下你的建议的原因。