cn.Execute "IF OBJECT_ID('tempdb..#a') IS NOT NULL DROP TABLE #a"
    
    cn.Execute "select IDENTITY (int, 1, 1) as ID,车间,系统,设备,sum(运行时间) as [累计时间(分钟)],count(*) as 累计次数 into #a from run  run1 where run1.车间=run.车间 and run1.系统=run.系统 and run1.设备=run.设备  order by 设备 asc"
    
请高手指点为什么我这么写运行的时候提示“列前缀"run"与查询中所有的表名或别名不匹配。  我再数据库中有RUN这个表的。

解决方案 »

  1.   

     cn.Execute "select IDENTITY (int, 1, 1) as ID,车间,系统,设备,sum(运行时间) as [累计时间(分钟)],count(*) as 累计次数 into #a from run  run1 
    你已经把run  改名为 run1了
      

  2.   

    少了个表runselect IDENTITY (int, 1, 1) as ID,车间,系统,设备,sum(运行时间) as [累计时间(分钟)],count(*) as 累计次数 
    into #a from run  run1 join run on run.id=run1.id where run1.车间=run.车间 and run1.系统=run.系统 and run1.设备=run.设备  order by 设备 asc
      

  3.   

    你的查询中已经将run用别名run1代替了.