日期:2014-05-18  浏览次数:21011 次

向变量赋值的 SELECT 语句不能与数据检索操作结合使用。
以下语名出现"向变量赋值的 SELECT 语句不能与数据检索操作结合使用。"
求解
declare @fdateb datetime,
  @fdatee datetime,
  @fnumberb varchar(255),
  @fnumbere varchar(255),
  @fstockname varchar(255)

select  
@fdateb='2012-05-01',@fdatee='2012-07-01',@fnumberb='1.06.ao.ab3.71',@fnumbere'1.06.yvf2.132',
@fstockname='材料一库'



select fnumber,fname,fmodel,w1.fqty1,w1.fqty2,w1.day1,w1.day2qty,w1.day3 from t_icitem w2,

(
select u1.fitemid as fitemid1,u2.fitemid as fitemid2,u2.fqty as fqty1,u1.fqty as fqty2,(u2.fqty-u1.fqty)fqtycha,datediff(d,@fdateb,@fdatee)as day1,convert (int,u1.fqty/datediff(d,@fdateb,@fdatee))as day2qty,convert(int,u2.fqty/(u1.fqty/datediff(d,@fdateb,@fdatee)))as day3,u2.fname as fstock from 
(
select t3.fitemid,t3.fnumber,t3.fname,t3.fmodel,sum(t2.fqty)fqty from icstockbill t1,icstockbillentry t2,t_icitem t3
where
t1.ftrantype=24 and t1.finterid=t2.finterid and t1.fdate between @fdateb and @fdatee
and t3.fitemid=t2.fitemid and t3.fnumber between @fnumberb and @fnumbere
and t2.fscstockid in (select fitemid from t_stock where fname=@fstockname)
and t2.fqty>0
group by t3.fitemid,t3.fnumber,t3.fname,t3.fmodel
)u1
full join
(
select t5.fitemid,t5.fnumber,t5.fmodel,t4.fqty,t6.fname from icinventory t4 ,t_icitem t5,t_stock t6
where t4.fitemid=t5.fitemid and t6.fname=@fstockname and t4.fstockid=t6.fitemid
and t5.fnumber between @fnumberb and @fnumbere
)u2
on u1.fitemid=u2.fitemid 
)w1 where( w2.fitemid=w1.fitemid1 or w2.fitemid=w1.fitemid2)


order by w2.fnumber
GO


------解决方案--------------------
@fnumbere'1.06.yvf2.132' 这里少个等号 结贴吧