读书人

一个奇怪的异常

发布时间: 2011-12-28 22:45:21 作者: rapoo

一个奇怪的错误
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

读书人网 >SQL Server

热点推荐