日期:2014-05-19  浏览次数:20676 次

一个奇怪的错误
declare   @isWastage   bit
declare   @partcode   varchar(20)

set   @isWastage=1
set   @PartCode= '1234567890 '

if   @isWastage=1       --要求计算结果包含损耗
      select   fpartcode,   dosage   INTO   #TMP2   from   tbom007d     where   fparentpartcode   =   @PartCode
else  
      select   fpartcode,   dosage*2   INTO   #TMP2   from   tbom007d     where   fparentpartcode   =   @PartCode                                         --这一行出错

出现以下错误:
服务器:   消息   2714,级别   16,状态   1,行   11
数据库中已存在名为   '#TMP2 '   的对象。

这是怎么回事啊?谢谢

------解决方案--------------------


if @isWastage=1
insert into #tmp2 select fpartcode, dosage from tbom007d where fparentpartcode = @PartCode
else
insert into #tmp2 select fpartcode, dosage*2 from tbom007d where fparentpartcode = @PartCode