update #temp1 set exampointid=(select exampointid from #temp2) where @id=@i+1 怎么会报错啊,报什么SQL不支持<=、>=等之类的,好像是update #temp1 set exampointid=(select exampointid from #temp2)这条语句出错了。

解决方案 »

  1.   

    update #temp1 set exampointid=(select exampointid from #temp2) where @id=@i+1 -->update #temp1 set exampointid = n.exampointid
    from #temp1 m, #temp2 n
    where m.关键字 = n.关键字
    and @id=@i+1 --这个条件哪里来的?
      

  2.   

    最好给出完整的表结构,测试数据,计算方法和正确结果.否则耽搁的是你宝贵的时间。发帖注意事项
    http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
      

  3.   

    报这样的?
    子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
    你的子查询是多个值
      

  4.   

    就只是将表的字段插入到一个临时表里面的,临时表:temp1 ,temp2 然后where @id=@i+1  是声明的一个变量,后面的WHERE字句不用管它,就是我执行update #temp1 set exampointid=(select exampointid from #temp2)这句话时有语法错误,但是我之前写的一个存储过程也是这样写的,没问题,这次不不知道为什么会有语法错误select exampointid from #temp2这句话执行出来取到的就是一个值,然后根据临时表temp1 来修改里面的exampointid。
      

  5.   

    对,就是报那个错误报这样的?
    子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
    你的子查询是多个值
      

  6.   

    select exampointid from #temp2 返回多值报错update #temp1 set exampointid=(select exampointid from #temp2) where @id=@i+1 字段也用参数的话 应该这样
    exec('update #temp1 set exampointid=(select exampointid from #temp2) where '+@id+'='+@i+1') 
      

  7.   

    你实在要这么做也简单,下的语句你自己选一个。update #temp1 set exampointid=(select top 1 exampointid from #temp2)update #temp1 set exampointid=(select top 1 exampointid from #temp2 order by ...)update #temp1 set exampointid=(select min(exampointid) from #temp2)update #temp1 set exampointid=(select max(exampointid) from #temp2)
      

  8.   

    update #temp1 set exampointid=#temp2.exampointid  from #temp1,#temp2 where #temp1.exampointid=#temp2.exampointid and  @id=@i+1